better.files

File

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
Learn more about member selection
Visibility
  1. Public
  2. All

Instance Constructors

  1. new File(_path: Path)

Value Members

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

  2. final def !=(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  3. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  4. final def ##(): Int

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

  6. def /(child: String): File

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

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

  9. def =!=(that: File): Boolean

  10. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  11. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  12. def ===(that: File): Boolean

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

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

  15. def addPermission(permission: PosixFilePermission): File

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

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

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

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

  20. def appendNewLine()(implicit codec: Codec): File

  21. def apply(permission: PosixFilePermission): Boolean

    test if file has this permission

  22. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  23. def attributes: BasicFileAttributes

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

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

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

  27. def byteArray: Array[Byte]

  28. def bytes: Iterator[Byte]

  29. def changeExtensionTo(extension: String): File

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

    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")

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

  31. def checksum(algorithm: String): String

    returns

    checksum of this file (or directory) in hex format

  32. def children: Files

  33. def clear(): File

    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

  34. def clone(): AnyRef

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

    Check if this directory contains this file

    Check if this directory contains this file

    file
    returns

    true if this is a directory and it contains this file

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

  37. def contentType: Option[String]

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

    destination
    overwrite
    returns

    destination

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

  40. def createDirectories(): File

  41. def createDirectory(): File

  42. def createIfNotExists(asDirectory: Boolean = false): File

  43. def delete(ignoreIOExceptions: Boolean = false): File

    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)

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

  45. def dosAttributes: DosFileAttributes

  46. def entries: Files

  47. final def eq(arg0: AnyRef): Boolean

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

    Definition Classes
    File → AnyRef → Any
  49. def exists: Boolean

  50. def extension: Option[String]

    returns

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

  51. def fileChannel: ManagedResource[FileChannel]

  52. def fileReader: ManagedResource[FileReader]

  53. def fileSystem: FileSystem

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

  55. def finalize(): Unit

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

  57. final def getClass(): Class[_]

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

    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

  59. def group: GroupPrincipal

  60. def groupName: String

  61. def hasExtension: Boolean

  62. def hashCode(): Int

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

  64. def isChildOf(parent: File): Boolean

  65. def isDirectory: Boolean

    returns

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

  66. def isEmpty: Boolean

    returns

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

  67. def isExecutable: Boolean

  68. def isGroupExecutable: Boolean

  69. def isGroupReadable: Boolean

  70. def isGroupWritable: Boolean

  71. def isHidden: Boolean

  72. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  73. def isOtherExecutable: Boolean

  74. def isOtherReadable: Boolean

  75. def isOtherWritable: Boolean

  76. def isOwnerExecutable: Boolean

  77. def isOwnerReadable: Boolean

  78. def isOwnerWritable: Boolean

  79. def isParentOf(child: File): Boolean

  80. def isReadable: Boolean

    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

    returns

    See also

    isOwnerReadable

  81. def isRegularFile: Boolean

    returns

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

  82. def isSameContentAs(that: File): Boolean

    returns

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

  83. def isSameFileAs(that: File): Boolean

  84. def isSamePathAs(that: File): Boolean

  85. def isSimilarContentAs(that: File): Boolean

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

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

    that
    returns

  86. def isSymbolicLink: Boolean

  87. def isWriteable: Boolean

  88. def lastModifiedTime: Instant

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

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

  91. def list: Files

  92. def listRecursively: Files

  93. def listRelativePaths: Iterator[Path]

  94. def loadBytes: Array[Byte]

  95. def md5: String

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

    destination
    overwrite
    returns

    destination

  97. def name: String

  98. def nameWithoutExtension: String

  99. final def ne(arg0: AnyRef): Boolean

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

  101. def newBufferedSource(implicit codec: Codec): BufferedSource

  102. def newBufferedWriter(implicit codec: Codec): BufferedWriter

  103. def newFileChannel: FileChannel

  104. def newFileReader: FileReader

  105. def newFileWriter(append: Boolean = false): FileWriter

  106. def newInputStream: InputStream

  107. def newOutputStream: OutputStream

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

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

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

  111. def newWatchService: WatchService

  112. def notExists: Boolean

  113. final def notify(): Unit

    Definition Classes
    AnyRef
  114. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  115. def outputStream: ManagedResource[OutputStream]

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

  117. def owner: UserPrincipal

  118. def ownerName: String

  119. def parent: File

  120. val path: Path

  121. def permissions: Set[PosixFilePermission]

  122. def posixAttributes: PosixFileAttributes

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

  124. def relativize(destination: File): Path

  125. def removePermission(permission: PosixFilePermission): File

  126. def renameTo(newName: String): File

  127. def root: File

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

  129. def setGroup(group: String): File

  130. def setOwner(owner: String): File

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

  132. def size: Long

    returns

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

  133. def symbolicLink: Option[File]

    returns

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

  134. def symbolicLinkTo(destination: File): Path

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

    Definition Classes
    AnyRef
  136. def toJava: java.io.File

  137. def toString(): String

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

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

  139. def unzip(): File

    unzip to a temporary zip file

    unzip to a temporary zip file

    returns

    the zip file

  140. def unzipTo(destination: File): File

    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

  141. def uri: URI

  142. final def wait(): Unit

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

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

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

    Walk the directory tree recursively upto maxDepth

    Walk the directory tree recursively upto maxDepth

    maxDepth
    returns

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

  146. def watchService: ManagedResource[WatchService]

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

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

    Write byte array to file.

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

    bytes
    returns

    this

  149. def zip(): File

    zip to a temp directory

    zip to a temp directory

    returns

    the target directory

  150. def zipTo(destination: File): File

    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