Class/Object

better.files

File

Related Docs: object File | package files

Permalink

class File extends AnyRef

Scala wrapper around java.nio.files.Path

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. File
  2. AnyRef
  3. Any
  1. Hide All
  2. Show all
Visibility
  1. Public
  2. All

Instance Constructors

  1. new File(_path: Path)

    Permalink

Value Members

  1. def !(implicit codec: Codec): String

    Permalink
  2. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  4. def /(f: (File) ⇒ File): File

    Permalink
  5. def /(child: String): File

    Permalink
  6. def <(text: String)(implicit codec: Codec): File

    Permalink
  7. def <<(line: String)(implicit codec: Codec): File

    Permalink
  8. def =!=(that: File): Boolean

    Permalink
  9. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  10. def ===(that: File): Boolean

    Permalink
  11. def >:(text: String)(implicit codec: Codec): File

    Permalink
  12. def >>:(line: String)(implicit codec: Codec): File

    Permalink
  13. def addPermission(permission: PosixFilePermission): File

    Permalink
  14. def append(bytes: Array[Byte]): File

    Permalink
  15. def append(text: String)(implicit codec: Codec): File

    Permalink
  16. def appendLine(line: String)(implicit codec: Codec): File

    Permalink
  17. def appendLines(lines: String*)(implicit codec: Codec): File

    Permalink
  18. def appendNewLine()(implicit codec: Codec): File

    Permalink
  19. def apply(permission: PosixFilePermission): Boolean

    Permalink

    test if file has this permission

  20. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  21. def attributes: BasicFileAttributes

    Permalink
  22. def bufferedReader(implicit codec: Codec): ManagedResource[BufferedReader]

    Permalink
  23. def bufferedSource(implicit codec: Codec): ManagedResource[BufferedSource]

    Permalink
  24. def bufferedWriter(implicit codec: Codec): ManagedResource[BufferedWriter]

    Permalink
  25. def byteArray: Array[Byte]

    Permalink
  26. def bytes: Iterator[Byte]

    Permalink
  27. def changeExtensionTo(extension: String): File

    Permalink

    Changes the file-extension by renaming this file; if file does not have an extension, it adds the extension Example usage file"foo.java".changeExtensionTo(".scala")

  28. def chars(implicit codec: Codec): Iterator[Char]

    Permalink
  29. def checksum(algorithm: String): String

    Permalink

    returns

    checksum of this file (or directory) in hex format

  30. def children: Files

    Permalink
  31. def clear(): File

    Permalink

    If this is a directory, remove all its children If its a file, empty the contents

    If this is a directory, remove all its children If its a file, empty the contents

    returns

    this

  32. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  33. def contains(file: File): Boolean

    Permalink

    Check if this directory contains this file

    Check if this directory contains this file

    returns

    true if this is a directory and it contains this file

  34. def contentAsString(implicit codec: Codec): String

    Permalink
  35. def contentType: Option[String]

    Permalink
  36. def copyTo(destination: File, overwrite: Boolean = false): File

    Permalink

    returns

    destination

  37. def createChild(child: String, asDirectory: Boolean = false): File

    Permalink
  38. def createDirectories(): File

    Permalink
  39. def createDirectory(): File

    Permalink
  40. def createIfNotExists(asDirectory: Boolean = false): File

    Permalink
  41. def delete(ignoreIOExceptions: Boolean = false): File

    Permalink

    Deletes this file or directory

    Deletes this file or directory

    ignoreIOExceptions

    If this is set to true, an exception is thrown when delete fails (else it is swallowed)

  42. def digest(algorithm: String): Array[Byte]

    Permalink
  43. def dosAttributes: DosFileAttributes

    Permalink
  44. def entries: Files

    Permalink
  45. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  46. def equals(obj: Any): Boolean

    Permalink
    Definition Classes
    File → AnyRef → Any
  47. def exists: Boolean

    Permalink
  48. def extension: Option[String]

    Permalink

    returns

    extension (including the dot) of this file if it is a regular file and has an extension, else None

  49. def fileChannel: ManagedResource[FileChannel]

    Permalink
  50. def fileReader: ManagedResource[FileReader]

    Permalink
  51. def fileSystem: FileSystem

    Permalink
  52. def fileWriter(append: Boolean = false): ManagedResource[FileWriter]

    Permalink
  53. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  54. def fullPath: String

    Permalink
  55. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  56. def glob(pattern: String, syntax: String = "glob", ignoreIOExceptions: Boolean = false): Files

    Permalink

    Util to glob from this file's path

    Util to glob from this file's path

    ignoreIOExceptions

    when set to true, any file visit exceptions (e.g. a read or permission error) would be silently ignored

    returns

    Set of files that matched

  57. def group: GroupPrincipal

    Permalink
  58. def groupName: String

    Permalink
  59. def hasExtension: Boolean

    Permalink
  60. def hashCode(): Int

    Permalink
    Definition Classes
    File → AnyRef → Any
  61. def inputStream: ManagedResource[InputStream]

    Permalink
  62. def isChildOf(parent: File): Boolean

    Permalink
  63. def isDirectory: Boolean

    Permalink

    returns

    true if this file (or the file found by following symlink) is a directory

  64. def isEmpty: Boolean

    Permalink

    returns

    true if file is not present or empty directory or 0-bytes file

  65. def isExecutable: Boolean

    Permalink
  66. def isGroupExecutable: Boolean

    Permalink
  67. def isGroupReadable: Boolean

    Permalink
  68. def isGroupWritable: Boolean

    Permalink
  69. def isHidden: Boolean

    Permalink
  70. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  71. def isOtherExecutable: Boolean

    Permalink
  72. def isOtherReadable: Boolean

    Permalink
  73. def isOtherWritable: Boolean

    Permalink
  74. def isOwnerExecutable: Boolean

    Permalink
  75. def isOwnerReadable: Boolean

    Permalink
  76. def isOwnerWritable: Boolean

    Permalink
  77. def isParentOf(child: File): Boolean

    Permalink
  78. def isReadable: Boolean

    Permalink

    This differs from the above as this checks if the JVM can read this file even though the OS cannot in certain platforms

    This differs from the above as this checks if the JVM can read this file even though the OS cannot in certain platforms

    See also

    isOwnerReadable

  79. def isRegularFile: Boolean

    Permalink

    returns

    true if this file (or the file found by following symlink) is a regular file

  80. def isSameContentAs(that: File): Boolean

    Permalink

    returns

    true if this file is exactly same as that file For directories, it checks for equivalent directory structure

  81. def isSameFileAs(that: File): Boolean

    Permalink
  82. def isSamePathAs(that: File): Boolean

    Permalink
  83. def isSimilarContentAs(that: File): Boolean

    Permalink

    Almost same as isSameContentAs but uses faster md5 hashing to compare (and thus small chance of false positive) Also works for directories

  84. def isSymbolicLink: Boolean

    Permalink
  85. def isWriteable: Boolean

    Permalink
  86. def lastModifiedTime: Instant

    Permalink
  87. def lines(implicit codec: Codec): Iterator[String]

    Permalink
  88. def linkTo(destination: File, symbolic: Boolean = false): File

    Permalink
  89. def list: Files

    Permalink
  90. def listRecursively: Files

    Permalink
  91. def listRelativePaths: Iterator[Path]

    Permalink
  92. def loadBytes: Array[Byte]

    Permalink
  93. def md5: String

    Permalink
  94. def moveTo(destination: File, overwrite: Boolean = false): File

    Permalink

    returns

    destination

  95. def name: String

    Permalink
  96. def nameWithoutExtension: String

    Permalink
  97. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  98. def newBufferedReader(implicit codec: Codec): BufferedReader

    Permalink
  99. def newBufferedSource(implicit codec: Codec): BufferedSource

    Permalink
  100. def newBufferedWriter(implicit codec: Codec): BufferedWriter

    Permalink
  101. def newFileChannel: FileChannel

    Permalink
  102. def newFileReader: FileReader

    Permalink
  103. def newFileWriter(append: Boolean = false): FileWriter

    Permalink
  104. def newInputStream: InputStream

    Permalink
  105. def newOutputStream: OutputStream

    Permalink
  106. def newRandomAccess(mode: String = "r"): RandomAccessFile

    Permalink
  107. def newScanner(delimiter: String = Scanner.defaultDelimiter, includeDelimiters: Boolean = false)(implicit codec: Codec): Scanner

    Permalink
  108. def newWatchKey(events: Kind[_]*): WatchKey

    Permalink
  109. def newWatchService: WatchService

    Permalink
  110. def notExists: Boolean

    Permalink
  111. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  112. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  113. def outputStream: ManagedResource[OutputStream]

    Permalink
  114. def overwrite(text: String)(implicit codec: Codec): File

    Permalink
  115. def owner: UserPrincipal

    Permalink
  116. def ownerName: String

    Permalink
  117. def parent: File

    Permalink
  118. val path: Path

    Permalink
  119. def permissions: Set[PosixFilePermission]

    Permalink
  120. def posixAttributes: PosixFileAttributes

    Permalink
  121. def randomAccess(mode: String = "r"): ManagedResource[RandomAccessFile]

    Permalink
  122. def relativize(destination: File): Path

    Permalink
  123. def removePermission(permission: PosixFilePermission): File

    Permalink
  124. def renameTo(newName: String): File

    Permalink
  125. def root: File

    Permalink
  126. def scanner(delimiter: String = Scanner.defaultDelimiter, includeDelimiters: Boolean = false)(implicit codec: Codec): ManagedResource[Scanner]

    Permalink
  127. def setGroup(group: String): File

    Permalink
  128. def setOwner(owner: String): File

    Permalink
  129. def setPermissions(permissions: Set[PosixFilePermission]): File

    Permalink
  130. def size: Long

    Permalink

    returns

    file size (for directories, return size of the directory) in bytes

  131. def symbolicLink: Option[File]

    Permalink

    returns

    Some(target) if this is a symbolic link (to target) else None

  132. def symbolicLinkTo(destination: File): Path

    Permalink
  133. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  134. def toJava: java.io.File

    Permalink
  135. def toString(): String

    Permalink
    Definition Classes
    File → AnyRef → Any
  136. def touch(time: Instant = Instant.now()): File

    Permalink

    Similar to the UNIX command touch - create this file if it does not exist and set its last modification time

  137. def unzip(): File

    Permalink

    unzip to a temporary zip file

    unzip to a temporary zip file

    returns

    the zip file

  138. def unzipTo(destination: File): File

    Permalink

    Unzips this zip file

    Unzips this zip file

    destination

    destination folder; Creates this if it does not exist

    returns

    The destination where contents are unzipped

  139. def uri: URI

    Permalink
  140. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  141. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  142. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  143. def walk(maxDepth: Int = Int.MaxValue): Files

    Permalink

    Walk the directory tree recursively upto maxDepth

    Walk the directory tree recursively upto maxDepth

    returns

    List of children in BFS maxDepth level deep (includes self since self is at depth = 0)

  144. def watchService: ManagedResource[WatchService]

    Permalink
  145. def write(text: String)(implicit codec: Codec): File

    Permalink
  146. def write(bytes: Array[Byte]): File

    Permalink

    Write byte array to file.

    Write byte array to file. For large files, piping in streams is recommended

    returns

    this

  147. def zip(): File

    Permalink

    zip to a temp directory

    zip to a temp directory

    returns

    the target directory

  148. def zipTo(destination: File): File

    Permalink

    Zips this file (or directory)

    Zips this file (or directory)

    destination

    The destination file; Creates this if it does not exists

    returns

    The destination zip file

Inherited from AnyRef

Inherited from Any

Ungrouped