scala.io

class File

[source: scala/io/File.scala]

class File(val file : java.io.File)
extends Iterable[File]
An abstraction for files. For now it is little more than a wrapper around java.io.File.
Author
Paul Phillips
Since
2.8
Method Summary
def / (child : java.lang.String) : File
Creates a new File with the specified path appended.
def deleteRecursively : Boolean
Deletes the file or directory recursively. Returns false if it failed. Use with caution!
override def equals (other : Any) : Boolean
This method is used to compare the receiver object (this) with the argument object (arg0) for equivalence.
def extension : Option[java.lang.String]
Attempts to return the file extension.
override def hashCode : Int
Returns a hash code value for the object.
def inputStream : java.io.FileInputStream
Obtains an InputStream.
def iterator : Iterator[File]
If file is a directory, an iterator over its contents. If not, an empty iterator.
def outputStream (append : Boolean) : java.io.FileOutputStream
Obtains a OutputStream.
def toSource : Source
Creates a Source from this file.
override def toString : java.lang.String
Returns a string representation of the object.
Methods inherited from Iterable
companion
Methods inherited from IterableTemplate
elements, foreach, isEmpty, foldRight, reduceRight, toIterable, head, takeRight, dropRight, sameElements, toStream, view, view, first, firstOption, toSeq, projection
Methods inherited from TraversableClass
newBuilder, genericBuilder, unzip, flatten, transpose
Methods inherited from TraversableTemplate
thisCollection, nonEmpty, size, hasDefiniteSize, ++, ++, map, flatMap, filter, filterMap, filterNot, remove, partition, groupBy, forall, exists, count, find, foldLeft, /:, :\, reduceLeft, reduceLeftOption, reduceRightOption, headOption, tail, last, lastOption, init, take, drop, slice, takeWhile, dropWhile, span, splitAt, copyToBuffer, copyToArray, copyToArray, toArray, toList, toSequence, toSet, mkString, mkString, mkString, addString, addString, addString, stringPrefix
Methods inherited from AnyRef
getClass, clone, notify, notifyAll, wait, wait, wait, finalize, ==, !=, eq, ne, synchronized
Methods inherited from Any
==, !=, isInstanceOf, asInstanceOf
Method Details
def iterator : Iterator[File]
If file is a directory, an iterator over its contents. If not, an empty iterator.

def deleteRecursively : Boolean
Deletes the file or directory recursively. Returns false if it failed. Use with caution!

def inputStream : java.io.FileInputStream
Obtains an InputStream.

def outputStream(append : Boolean) : java.io.FileOutputStream
Obtains a OutputStream.

def extension : Option[java.lang.String]
Attempts to return the file extension.

def toSource : Source
Creates a Source from this file.

def /(child : java.lang.String) : File
Creates a new File with the specified path appended.

override def toString : java.lang.String
Returns a string representation of the object.

The default representation is platform dependent.

Returns
a string representation of the object.


override def equals(other : Any) : Boolean
This method is used to compare the receiver object (this) with the argument object (arg0) for equivalence.

The default implementations of this method is an equivalence relation:

  • It is reflexive: for any instance x of type Any, x.equals(x) should return true.
  • It is symmetric: for any instances x and y of type Any, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any instances x, y, and z of type AnyRef if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.

If you override this method, you should verify that your implementation remains an equivalence relation. Additionally, when overriding this method it is often necessary to override hashCode to ensure that objects that are "equal" (o1.equals(o2) returns true) hash to the same Int (o1.hashCode.equals(o2.hashCode)).

Parameters
arg0 - the object to compare against this object for equality.
Returns
true if the receiver object is equivalent to the argument; false otherwise.


override def hashCode : Int
Returns a hash code value for the object.

The default hashing algorithm is platform dependent. Note that it is allowed for two objects to have identical hash codes (o1.hashCode.equals(o2.hashCode)) yet not be equal (o1.equals(o2) returns false). A degenerate implementation could always return 0. However, it is required that if two objects are equal (o1.equals(o2) returns true) that they have identical hash codes (o1.hashCode.equals(o2.hashCode)). Therefore, when overriding this method, be sure to verify that the behavior is consistent with the equals method.

Returns
the hash code value for the object.