class File extends Path with Chars
An abstraction for files. For character data, a Codec can be supplied at either creation time or when a method involving character data is called (with the latter taking precedence if supplied.) If neither is available, the value of scala.io.Codec.default is used.
- Since
2.8 Note: This is library is considered experimental and should not be used unless you know what you are doing.
- Alphabetic
- By Inheritance
- File
- Chars
- Bytes
- Path
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
- new File(jfile: java.io.File)(implicit constructorCodec: Codec)
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
def
/(child: File): File
- Definition Classes
- Path
-
def
/(child: Directory): Directory
- Definition Classes
- Path
-
def
/(child: Path): Path
Creates a new Path with the specified path appended.
Creates a new Path with the specified path appended. Assumes the type of the new component implies the type of the result.
- Definition Classes
- Path
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- def addExtension(ext: String): File
- def appendAll(strings: String*): Unit
-
def
applyReader[T](f: (BufferedReader) ⇒ T): T
Creates a BufferedReader and applies the closure, automatically closing it on completion.
Creates a BufferedReader and applies the closure, automatically closing it on completion.
- Definition Classes
- Chars
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
bufferedInput(): BufferedInputStream
- Definition Classes
- Bytes
- def bufferedOutput(append: Boolean = false): BufferedOutputStream
-
def
bufferedReader(codec: Codec): BufferedReader
- Definition Classes
- Chars
-
def
bufferedReader(): BufferedReader
Wraps a BufferedReader around the result of reader().
Wraps a BufferedReader around the result of reader().
- Definition Classes
- Chars
- def bufferedWriter(append: Boolean, codec: Codec): BufferedWriter
- def bufferedWriter(append: Boolean): BufferedWriter
-
def
bufferedWriter(): BufferedWriter
Wraps a BufferedWriter around the result of writer().
-
def
bytes(): Iterator[Byte]
- Definition Classes
- Bytes
-
def
bytesAsInts(): Iterator[Int]
- Definition Classes
- Bytes
-
def
canRead: Boolean
- Definition Classes
- Path
-
def
canWrite: Boolean
- Definition Classes
- Path
-
def
changeExtension(ext: String): Path
- Definition Classes
- Path
-
def
chars(codec: Codec): BufferedSource
Caller is responsible for closing the returned BufferedSource.
Caller is responsible for closing the returned BufferedSource.
- Definition Classes
- Chars
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
-
def
createDirectory(force: Boolean = true, failIfExists: Boolean = false): Directory
- Definition Classes
- Path
-
def
createFile(failIfExists: Boolean = false): File
- Definition Classes
- Path
-
val
creationCodec: Codec
Calls to methods requiring byte<->char transformations should be offered in a form which allows specifying the codec.
Calls to methods requiring byte<->char transformations should be offered in a form which allows specifying the codec. When it is not specified, the one discovered at creation time will be used, which will always find the one in scala.io.Codec if no other is available. This can be overridden to use a different default.
-
def
delete(): Boolean
- Definition Classes
- Path
-
def
deleteRecursively(): Boolean
Deletes the path recursively.
Deletes the path recursively. Returns false on failure. Use with caution!
- Definition Classes
- Path
-
def
endsWith(other: Path): Boolean
- Definition Classes
- Path
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(other: Any): Boolean
- Definition Classes
- Path → AnyRef → Any
-
def
exists: Boolean
- Definition Classes
- Path
-
def
extension: String
- Definition Classes
- Path
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
hasExtension(ext: String, exts: String*): Boolean
- Definition Classes
- Path
-
def
hashCode(): Int
- Definition Classes
- Path → AnyRef → Any
-
def
ifDirectory[T](f: (Directory) ⇒ T): Option[T]
- Definition Classes
- Path
-
def
ifFile[T](f: (File) ⇒ T): Option[T]
- Definition Classes
- Path
-
def
inputStream(): FileInputStream
Obtains an InputStream.
-
def
isAbsolute: Boolean
- Definition Classes
- Path
-
def
isDirectory: Boolean
- Definition Classes
- Path
-
def
isEmpty: Boolean
- Definition Classes
- Path
-
def
isFile: Boolean
- Definition Classes
- Path
-
def
isFresher(other: Path): Boolean
- Definition Classes
- Path
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
isSame(other: Path): Boolean
- Definition Classes
- Path
-
val
jfile: java.io.File
- Definition Classes
- Path
-
def
lastModified: Long
- Definition Classes
- Path
- def length: Long
-
def
lines(codec: Codec): Iterator[String]
Beware! Leaks an InputStream which will not be closed until it gets finalized.
Beware! Leaks an InputStream which will not be closed until it gets finalized.
- Definition Classes
- Chars
-
def
lines(): Iterator[String]
Beware! Leaks an InputStream which will not be closed until it gets finalized.
Beware! Leaks an InputStream which will not be closed until it gets finalized.
- Definition Classes
- Chars
-
def
name: String
- Definition Classes
- Path
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def normalize: File
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
def
outputStream(append: Boolean = false): FileOutputStream
Obtains a OutputStream.
-
def
parent: Directory
- returns
The path of the parent directory, or root if path is already root
- Definition Classes
- Path
-
def
parents: List[Directory]
- Definition Classes
- Path
-
def
path: String
- Definition Classes
- Path
- def printWriter(): PrintWriter
-
def
printlnAll(strings: String*): Unit
Calls println on each string (so it adds a newline in the PrintWriter fashion.)
-
def
reader(codec: Codec): InputStreamReader
Obtains an InputStreamReader wrapped around a FileInputStream.
Obtains an InputStreamReader wrapped around a FileInputStream.
- Definition Classes
- Chars
-
def
relativize(other: Path): Path
- Definition Classes
- Path
-
def
resolve(other: Path): Path
- Definition Classes
- Path
- def safeSlurp(): Option[String]
-
def
segments: List[String]
- Definition Classes
- Path
-
val
separator: Char
- Definition Classes
- Path
-
val
separatorStr: String
- Definition Classes
- Path
-
def
setExecutable(executable: Boolean, ownerOnly: Boolean = true): Boolean
Reflection since we're into the java 6+ API.
-
def
slurp(codec: Codec): String
- Definition Classes
- Chars
-
def
slurp(): String
Convenience function to import entire file into a String.
Convenience function to import entire file into a String.
- Definition Classes
- Chars
-
def
stripExtension: String
- Definition Classes
- Path
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
- def toAbsolute: File
-
def
toAbsoluteWithRoot(root: Path): Path
If this path is absolute, returns it: otherwise, returns an absolute path made up of root / this.
If this path is absolute, returns it: otherwise, returns an absolute path made up of root / this.
- Definition Classes
- Path
-
def
toByteArray(): Array[Byte]
This method aspires to be the fastest way to read a stream of known length into memory.
This method aspires to be the fastest way to read a stream of known length into memory.
- Definition Classes
- Bytes
-
def
toCanonical: Path
- Definition Classes
- Path
- def toDirectory: Directory
- def toFile: File
-
def
toString(): String
- Definition Classes
- Path → AnyRef → Any
-
def
toURI: URI
- Definition Classes
- Path
-
def
toURL: URL
- Definition Classes
- Path
-
def
truncate(): Boolean
- Definition Classes
- Path
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
-
def
walk: Iterator[Path]
Equivalent to walkFilter(_ => true).
Equivalent to walkFilter(_ => true).
- Definition Classes
- Path
-
def
walkFilter(cond: (Path) ⇒ Boolean): Iterator[Path]
If this path is a directory, recursively iterate over its contents.
If this path is a directory, recursively iterate over its contents. The supplied condition is a filter which is applied to each element, with that branch of the tree being closed off if it is false. So for example if the condition is false for some subdirectory, nothing under that directory will be in the Iterator. If it's true, all files for which the condition holds and are directly in that subdirectory are in the Iterator, and all sub-subdirectories are recursively evaluated
-
def
writeAll(strings: String*): Unit
Creates a new file and writes all the Strings to it.
-
def
writer(append: Boolean, codec: Codec): OutputStreamWriter
Obtains an OutputStreamWriter wrapped around a FileOutputStream.
Obtains an OutputStreamWriter wrapped around a FileOutputStream. This should behave like a less broken version of java.io.FileWriter, in that unlike the java version you can specify the encoding.