jp.mwsoft.commonsfile

CommonsFileUtils

trait CommonsFileUtils extends AnyRef

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

Abstract Value Members

  1. val that : File

    Attributes
    protected abstract

Concrete Value Members

  1. def != (arg0: AnyRef): Boolean

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

    Attributes
    final
    Definition Classes
    Any
  3. def ## (): Int

    Attributes
    final
    Definition Classes
    AnyRef → Any
  4. def == (arg0: AnyRef): Boolean

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

    Attributes
    final
    Definition Classes
    Any
  6. def asInstanceOf [T0] : T0

    Attributes
    final
    Definition Classes
    Any
  7. def checksum (checksum: Checksum): Checksum

    Computes the checksum of a file using the specified checksum object.

    Computes the checksum of a file using the specified checksum object. Multiple files may be checked using one Checksum instance if desired simply by reusing the same checksum object. For example:

      long csum = FileUtils.checksum(file, new CRC32()).getValue();
    

    checksum

    the checksum object to be used, must not be null

    returns

    the checksum specified, updated with the content of the file

  8. def checksumCRC32 : Long

    Computes the checksum of a file using the CRC32 checksum routine.

    Computes the checksum of a file using the CRC32 checksum routine. The value of the checksum is returned.

  9. def cleanDir (): File

    Cleans a directory without deleting it.

    Cleans a directory without deleting it.

    returns

    this file

  10. def clone (): AnyRef

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  11. def contentEquals (file: File): Boolean

    Compares the contents of two files to determine if they are equal or not.

    Compares the contents of two files to determine if they are equal or not.

    This method checks to see if the two files are different lengths or if they point to the same file, before resorting to byte-by-byte comparison of the contents.

    Code origin: Avalon

    file

    the second file

    returns

    true if the content of the files are equal or they both don't exist, false otherwise

  12. def copyDir (destDir: String, filter: FileFilter, preserveFileDate: Boolean): File

    Copies a filtered directory to a new location.

    Copies a filtered directory to a new location.

    This method copies the contents of the specified source directory to within the specified destination directory.

    The destination directory is created if it does not exist. If the destination directory did exist, then this method merges the source with the destination, with the source taking precedence.

    Note: Setting preserveFileDate to true tries to preserve the files' last modified date/times using File#setLastModified(long), however it is not guaranteed that those operations will succeed. If the modification operation fails, no indication is provided.

    destDir

    the new directory, must not be null

    filter

    the filter to apply, null means copy all directories and files

    preserveFileDate

    true if the file date of the copy should be the same as the original

    returns

    the destination file

  13. def copyDir (destDir: String, filter: FileFilter): File

    Copies a filtered directory to a new location.

    Copies a filtered directory to a new location.

    This method copies the contents of the specified source directory to within the specified destination directory.

    The destination directory is created if it does not exist. If the destination directory did exist, then this method merges the source with the destination, with the source taking precedence.

    Note: Setting preserveFileDate to true tries to preserve the files' last modified date/times using File#setLastModified(long), however it is not guaranteed that those operations will succeed. If the modification operation fails, no indication is provided.

    destDir

    the new directory, must not be null

    filter

    the filter to apply, null means copy all directories and files

    returns

    the destination file

  14. def copyDir (destDir: File, filter: FileFilter, preserveFileDate: Boolean): File

    Copies a filtered directory to a new location.

    Copies a filtered directory to a new location.

    This method copies the contents of the specified source directory to within the specified destination directory.

    The destination directory is created if it does not exist. If the destination directory did exist, then this method merges the source with the destination, with the source taking precedence.

    Note: Setting preserveFileDate to true tries to preserve the files' last modified date/times using File#setLastModified(long), however it is not guaranteed that those operations will succeed. If the modification operation fails, no indication is provided.

    Example: Copy directories only

     // only copy the directory structure
     copyDir(destDir, (file: File => file.isDirectory), false);
    

    destDir

    the new directory, must not be null

    filter

    the filter to apply, null means copy all directories and files

    preserveFileDate

    true if the file date of the copy should be the same as the original

    returns

    the destination file

  15. def copyDir (destDir: File, filter: FileFilter): File

    Copies a filtered directory to a new location.

    Copies a filtered directory to a new location.

    This method copies the contents of the specified source directory to within the specified destination directory.

    The destination directory is created if it does not exist. If the destination directory did exist, then this method merges the source with the destination, with the source taking precedence.

    Note: Setting preserveFileDate to true tries to preserve the files' last modified date/times using File#setLastModified(long), however it is not guaranteed that those operations will succeed. If the modification operation fails, no indication is provided.

    Example: Copy directories only

     // only copy the directory structure
     copyDir(destDir, (file: File => file.isDirectory), false);
    

    destDir

    the new directory, must not be null

    filter

    the filter to apply, null means copy all directories and files

    returns

    the destination file

  16. def copyDir (destDir: String): File

    Copies a whole directory to a new location.

    Copies a whole directory to a new location.

    This method copies the contents of the specified source directory to within the specified destination directory.

    The destination directory is created if it does not exist. If the destination directory did exist, then this method merges the source with the destination, with the source taking precedence.

    Note: Setting preserveFileDate to true tries to preserve the files' last modified date/times using File#setLastModified(long), however it is not guaranteed that those operations will succeed. If the modification operation fails, no indication is provided.

    destDir

    the new directory, must not be null should be the same as the original

    returns

    the destination file

  17. def copyDir (destDir: String, preserveFileDate: Boolean): File

    Copies a whole directory to a new location.

    Copies a whole directory to a new location.

    This method copies the contents of the specified source directory to within the specified destination directory.

    The destination directory is created if it does not exist. If the destination directory did exist, then this method merges the source with the destination, with the source taking precedence.

    Note: Setting preserveFileDate to true tries to preserve the files' last modified date/times using File#setLastModified(long), however it is not guaranteed that those operations will succeed. If the modification operation fails, no indication is provided.

    destDir

    the new directory, must not be null

    preserveFileDate

    true if the file date of the copy should be the same as the original

    returns

    the destination file

  18. def copyDir (destDir: File): File

    Copies a whole directory to a new location.

    Copies a whole directory to a new location.

    This method copies the contents of the specified source directory to within the specified destination directory.

    The destination directory is created if it does not exist. If the destination directory did exist, then this method merges the source with the destination, with the source taking precedence.

    Note: Setting preserveFileDate to true tries to preserve the files' last modified date/times using File#setLastModified(long), however it is not guaranteed that those operations will succeed. If the modification operation fails, no indication is provided.

    destDir

    the new directory, must not be null

    returns

    the destination file

  19. def copyDir (destDir: File, preserveFileDate: Boolean): File

    Copies a whole directory to a new location.

    Copies a whole directory to a new location.

    This method copies the contents of the specified source directory to within the specified destination directory.

    The destination directory is created if it does not exist. If the destination directory did exist, then this method merges the source with the destination, with the source taking precedence.

    Note: Setting preserveFileDate to true tries to preserve the files' last modified date/times using File#setLastModified(long), however it is not guaranteed that those operations will succeed. If the modification operation fails, no indication is provided.

    destDir

    the new directory, must not be null

    returns

    the destination file

  20. def copyDirToDir (destDir: String): File

    Copies a directory to within another directory preserving the file dates.

    Copies a directory to within another directory preserving the file dates.

    This method copies the source directory and all its contents to a directory of the same name in the specified destination directory.

    The destination directory is created if it does not exist. If the destination directory did exist, then this method merges the source with the destination, with the source taking precedence.

    Note: This method tries to preserve the files' last modified date/times using File#setLastModified(long), however it is not guaranteed that those operations will succeed. If the modification operation fails, no indication is provided.

    destDir

    the directory to place the copy in, must not be null

    returns

    the destination file

  21. def copyDirToDir (destDir: File): File

    Copies a directory to within another directory preserving the file dates.

    Copies a directory to within another directory preserving the file dates.

    This method copies the source directory and all its contents to a directory of the same name in the specified destination directory.

    The destination directory is created if it does not exist. If the destination directory did exist, then this method merges the source with the destination, with the source taking precedence.

    Note: This method tries to preserve the files' last modified date/times using File#setLastModified(long), however it is not guaranteed that those operations will succeed. If the modification operation fails, no indication is provided.

    destDir

    the directory to place the copy in, must not be null

    returns

    the destination file

  22. def copyFile (destFile: String): File

    Copies a file to a new location.

    Copies a file to a new location.

    This method copies the contents of the specified source file to the specified destination file. The directory holding the destination file is created if it does not exist. If the destination file exists, then this method will overwrite it.

    destFile

    the new file, must not be null

    returns

    the destination file

  23. def copyFile (destFile: String, preserveFileDate: Boolean): File

    Copies a file to a new location.

    Copies a file to a new location.

    This method copies the contents of the specified source file to the specified destination file. The directory holding the destination file is created if it does not exist. If the destination file exists, then this method will overwrite it.

    Note: Setting preserveFileDate to true tries to preserve the file's last modified date/times using File#setLastModified(long), however it is not guaranteed that the operation will succeed. If the modification operation fails, no indication is provided.

    destFile

    the new file, must not be null

    preserveFileDate

    true if the file date of the copy should be the same as the original

    returns

    the destination file

  24. def copyFile (destFile: File): File

    Copies a file to a new location.

    Copies a file to a new location.

    This method copies the contents of the specified source file to the specified destination file. The directory holding the destination file is created if it does not exist. If the destination file exists, then this method will overwrite it.

    destFile

    the new file, must not be null

    returns

    the destination file

  25. def copyFile (destFile: File, preserveFileDate: Boolean): File

    Copies a file to a new location.

    Copies a file to a new location.

    This method copies the contents of the specified source file to the specified destination file. The directory holding the destination file is created if it does not exist. If the destination file exists, then this method will overwrite it.

    Note: Setting preserveFileDate to true tries to preserve the file's last modified date/times using File#setLastModified(long), however it is not guaranteed that the operation will succeed. If the modification operation fails, no indication is provided.

    destFile

    the new file, must not be null

    preserveFileDate

    true if the file date of the copy should be the same as the original

    returns

    the destination file

  26. def copyFileToDir (destDir: String): File

    Copies a file to a directory optionally preserving the file date.

    Copies a file to a directory optionally preserving the file date.

    This method copies the contents of the specified source file to a file of the same name in the specified destination directory. The destination directory is created if it does not exist. If the destination file exists, then this method will overwrite it.

    Note: Setting preserveFileDate to true tries to preserve the file's last modified date/times using File#setLastModified(long), however it is not guaranteed that the operation will succeed. If the modification operation fails, no indication is provided.

    destDir

    the directory to place the copy in, must not be null

    returns

    the destination file

  27. def copyFileToDir (destDir: String, preserveFileDate: Boolean): File

    Copies a file to a directory optionally preserving the file date.

    Copies a file to a directory optionally preserving the file date.

    This method copies the contents of the specified source file to a file of the same name in the specified destination directory. The destination directory is created if it does not exist. If the destination file exists, then this method will overwrite it.

    Note: Setting preserveFileDate to true tries to preserve the file's last modified date/times using File#setLastModified(long), however it is not guaranteed that the operation will succeed. If the modification operation fails, no indication is provided.

    destDir

    the directory to place the copy in, must not be null

    preserveFileDate

    true if the file date of the copy should be the same as the original

    returns

    the destination file

  28. def copyFileToDir (destDir: File): File

    Copies a file to a directory optionally preserving the file date.

    Copies a file to a directory optionally preserving the file date.

    This method copies the contents of the specified source file to a file of the same name in the specified destination directory. The destination directory is created if it does not exist. If the destination file exists, then this method will overwrite it.

    Note: Setting preserveFileDate to true tries to preserve the file's last modified date/times using File#setLastModified(long), however it is not guaranteed that the operation will succeed. If the modification operation fails, no indication is provided.

    destDir

    the directory to place the copy in, must not be null

    returns

    the destination file

  29. def copyFileToDir (destDir: File, preserveFileDate: Boolean): File

    Copies a file to a directory optionally preserving the file date.

    Copies a file to a directory optionally preserving the file date.

    This method copies the contents of the specified source file to a file of the same name in the specified destination directory. The destination directory is created if it does not exist. If the destination file exists, then this method will overwrite it.

    Note: Setting preserveFileDate to true tries to preserve the file's last modified date/times using File#setLastModified(long), however it is not guaranteed that the operation will succeed. If the modification operation fails, no indication is provided.

    destDir

    the directory to place the copy in, must not be null

    preserveFileDate

    true if the file date of the copy should be the same as the original

    returns

    the destination file

  30. def copyFromInputStream (source: InputStream): File

    Copies bytes from an InputStream source to a file destination.

    Copies bytes from an InputStream source to a file destination. The directories up to destination will be created if they don't already exist. destination will be overwritten if it already exists.

    source

    the InputStream to copy bytes from, must not be null

    returns

    this file

  31. def copyFromURL (url: String, connectionTimeouut: Int, readTimeout: Int): File

    Copies bytes from the URL source to a file destination.

    Copies bytes from the URL source to a file destination. The directories up to destination will be created if they don't already exist. destination will be overwritten if it already exists.

    url

    the URL to copy bytes from, must not be null

    readTimeout

    the number of milliseconds until this method will timeout if no data could be read from the source

    returns

    this file

  32. def copyFromURL (url: URL, connectionTimeouut: Int, readTimeout: Int): File

    Copies bytes from the URL source to a file destination.

    Copies bytes from the URL source to a file destination. The directories up to destination will be created if they don't already exist. destination will be overwritten if it already exists.

    url

    the URL to copy bytes from, must not be null

    readTimeout

    the number of milliseconds until this method will timeout if no data could be read from the source

    returns

    this file

  33. def copyFromURL (url: String): File

    Copies bytes from the URL source to a file destination.

    Copies bytes from the URL source to a file destination. The directories up to destination will be created if they don't already exist. destination will be overwritten if it already exists.

    Warning: this method does not set a connection or read timeout and thus might block forever. Use #copyURLToFile(URL, File, int, int) with reasonable timeouts to prevent this.

    url

    the URL to copy bytes from, must not be null

    returns

    this file

  34. def copyFromURL (url: URL): File

    Copies bytes from the URL source to a file destination.

    Copies bytes from the URL source to a file destination. The directories up to destination will be created if they don't already exist. destination will be overwritten if it already exists.

    Warning: this method does not set a connection or read timeout and thus might block forever. Use #copyURLToFile(URL, File, int, int) with reasonable timeouts to prevent this.

    url

    the URL to copy bytes from, must not be null

    returns

    this file

  35. def deleteDir (): Unit

    Deletes a directory recursively.

  36. def deleteQuietly (): Boolean

    Deletes a file, never throwing an exception.

    Deletes a file, never throwing an exception. If file is a directory, delete it and all sub-directories.

    The difference between File.delete() and this method are:

    • A directory to be deleted does not have to be empty.
    • No exceptions are thrown when a file or directory cannot be deleted.
    returns

    true if the file or directory was deleted, otherwise false

  37. def displaySize : String

    Returns a human-readable version of the file size, where the input represents a specific number of bytes.

    Returns a human-readable version of the file size, where the input represents a specific number of bytes.

    If the size is over 1GB, the size is returned as the number of whole GB, i.e. the size is rounded down to the nearest GB boundary.

    Similarly for the 1MB and 1KB boundaries.

    returns

    a human-readable display value (includes units - GB, MB, KB or bytes)

  38. def eq (arg0: AnyRef): Boolean

    Attributes
    final
    Definition Classes
    AnyRef
  39. def equals (arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  40. def finalize (): Unit

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  41. def forceDelete (): Unit

    Deletes a file.

    Deletes a file. If file is a directory, delete it and all sub-directories.

    The difference between File.delete() and this method are:

    • A directory to be deleted does not have to be empty.
    • You get exceptions when a file or directory cannot be deleted. (java.io.File methods returns a boolean)
  42. def forceDeleteOnExit (): Unit

    Schedules a file to be deleted when JVM exits.

    Schedules a file to be deleted when JVM exits. If file is directory delete it and all sub-directories.

  43. def forceMkdir (): File

    Makes a directory, including any necessary but nonexistent parent directories.

    Makes a directory, including any necessary but nonexistent parent directories. If a file already exists with specified name but it is not a directory then an IOException is thrown. If the directory cannot be created (or does not already exist) then an IOException is thrown.

    returns

    this file

  44. def getClass (): java.lang.Class[_]

    Attributes
    final
    Definition Classes
    AnyRef
  45. def hashCode (): Int

    Definition Classes
    AnyRef → Any
  46. def isInstanceOf [T0] : Boolean

    Attributes
    final
    Definition Classes
    Any
  47. def isNewer (timeMillis: Long): Boolean

    Tests if the specified File is newer than the specified time reference.

    Tests if the specified File is newer than the specified time reference.

    timeMillis

    the time reference measured in milliseconds since the epoch (00:00:00 GMT, January 1, 1970)

    returns

    true if the File exists and has been modified after the given time reference.

  48. def isNewer (date: Date): Boolean

    Tests if the specified File is newer than the specified Date.

    Tests if the specified File is newer than the specified Date.

    date

    the date reference, must not be null

    returns

    true if the File exists and has been modified after the given Date.

  49. def isNewer (file: File): Boolean

    Tests if the specified File is newer than the reference File.

    Tests if the specified File is newer than the reference File.

    returns

    true if the File exists and has been modified more recently than the reference File

  50. def isOlder (timeMillis: Long): Boolean

    Tests if the specified File is older than the specified time reference.

    Tests if the specified File is older than the specified time reference.

    timeMillis

    the time reference measured in milliseconds since the epoch (00:00:00 GMT, January 1, 1970)

    returns

    true if the File exists and has been modified before the given time reference.

  51. def isOlder (date: Date): Boolean

    Tests if the specified File is older than the specified Date.

    Tests if the specified File is older than the specified Date.

    date

    the date reference, must not be null

    returns

    true if the File exists and has been modified before the given Date.

  52. def isOlder (reference: File): Boolean

    Tests if the specified File is older than the reference File.

    Tests if the specified File is older than the reference File.

    reference

    the File of which the modification date is used, must not be null

    returns

    true if the File exists and has been modified before the reference File

  53. def isSymlink : Boolean

    Determines whether the specified file is a Symbolic Link rather than an actual file.

    Determines whether the specified file is a Symbolic Link rather than an actual file.

    Will not return true if there is a Symbolic Link anywhere in the path, only if the specific file is.

    returns

    true if the file is a Symbolic Link

  54. def lineIterator (encoding: String = null): LineIterator

    Returns an Iterator for the lines in a File.

    Returns an Iterator for the lines in a File.

    This method opens an InputStream for the file. When you have finished with the iterator you should close the stream to free internal resources. This can be done by calling the LineIterator#close() or LineIterator#closeQuietly(LineIterator) method.

    The recommended usage pattern is:

    LineIterator it = file.lineIterator("UTF-8");
    try {
      while (it.hasNext()) {
        String line = it.nextLine();
        /// do something with line
      }
    } finally {
      LineIterator.closeQuietly(iterator);
    }
    

    If an exception occurs during the creation of the iterator, the underlying stream is closed.

    encoding

    the encoding to use, null means platform default

    returns

    an Iterator of the lines in the file, never null

  55. def listFiles (extensions: Array[String]): Array[File]

    Finds files within a given directory which match an array of extensions.

    Finds files within a given directory which match an array of extensions.

    extensions

    an array of extensions, ex. {"java","xml"}. If this parameter is null, all files are returned.

  56. def listFilesRecursive (extensions: Array[String]): Array[File]

    Finds files within a given directory and its subdirectories which match an array of extensions.

    Finds files within a given directory and its subdirectories which match an array of extensions.

    extensions

    an array of extensions, ex. {"java","xml"}. If this

  57. def listFilesRecursive : Array[File]

    Finds files within a given directory and its subdirectories.

  58. def modeDirToDir (destPath: String): File

    Moves a directory to another directory.

    Moves a directory to another directory. create the destination directory

    destPath

    the destination file

    returns

    the destination directory

  59. def modeDirToDir (destDir: File): File

    Moves a directory to another directory.

    Moves a directory to another directory. create the destination directory

    returns

    the destination directory

  60. def moveDir (destPath: String): File

    Moves a directory.

    Moves a directory.

    When the destination directory is on another file system, do a "copy and delete".

    returns

    the destination directory

  61. def moveDir (destDir: File): File

    Moves a directory.

    Moves a directory.

    When the destination directory is on another file system, do a "copy and delete".

    destDir

    the destination directory

    returns

    the destination directory

  62. def moveDirToDir (destPath: String, createDestDir: Boolean): File

    Moves a directory to another directory.

    Moves a directory to another directory.

    createDestDir

    If true create the destination directory, otherwise if false throw an IOException

    returns

    the destination directory

  63. def moveDirToDir (destDir: File, createDestDir: Boolean): File

    Moves a directory to another directory.

    Moves a directory to another directory.

    destDir

    the destination file

    createDestDir

    If true create the destination directory, otherwise if false throw an IOException

    returns

    the destination directory

  64. def moveFile (destPath: String): File

    Moves a file.

    Moves a file.

    When the destination file is on another file system, do a "copy and delete".

    destPath

    the destination file

    returns

    the destination file

  65. def moveFile (destFile: File): File

    Moves a file.

    Moves a file.

    When the destination file is on another file system, do a "copy and delete".

    destFile

    the destination file

    returns

    the destination file

  66. def moveFileToDir (destPath: String): File

    Moves a file to a directory.

    Moves a file to a directory. create the destination directory.

    returns

    the destination file

  67. def moveFileToDir (destDir: File): File

    Moves a file to a directory.

    Moves a file to a directory. create the destination directory.

    destDir

    the destination file

    returns

    the destination file

  68. def moveFileToDir (destPath: String, createDestDir: Boolean): File

    Moves a file to a directory.

    Moves a file to a directory.

    createDestDir

    If true create the destination directory, otherwise if false throw an IOException

    returns

    the destination file

  69. def moveFileToDir (destDir: File, createDestDir: Boolean): File

    Moves a file to a directory.

    Moves a file to a directory.

    destDir

    the destination file

    createDestDir

    If true create the destination directory, otherwise if false throw an IOException

    returns

    the destination file

  70. def moveToDir (destPath: String): File

    Moves a file or directory to the destination directory.

    Moves a file or directory to the destination directory. create the destination directory,

    When the destination is on another file system, do a "copy and delete".

    destPath

    the destination directory

    returns

    the destination file or directory

  71. def moveToDir (destDir: File): File

    Moves a file or directory to the destination directory.

    Moves a file or directory to the destination directory. create the destination directory,

    When the destination is on another file system, do a "copy and delete".

    destDir

    the destination directory

    returns

    the destination file or directory

  72. def moveToDir (destPath: String, createDestDir: Boolean): File

    Moves a file or directory to the destination directory.

    Moves a file or directory to the destination directory.

    When the destination is on another file system, do a "copy and delete".

    destPath

    the destination directory

    createDestDir

    If true create the destination directory, otherwise if false throw an IOException

    returns

    the destination file or directory

  73. def moveToDir (destDir: File, createDestDir: Boolean): File

    Moves a file or directory to the destination directory.

    Moves a file or directory to the destination directory.

    When the destination is on another file system, do a "copy and delete".

    destDir

    the destination directory

    createDestDir

    If true create the destination directory, otherwise if false throw an IOException

    returns

    the destination file or directory

  74. def ne (arg0: AnyRef): Boolean

    Attributes
    final
    Definition Classes
    AnyRef
  75. def notify (): Unit

    Attributes
    final
    Definition Classes
    AnyRef
  76. def notifyAll (): Unit

    Attributes
    final
    Definition Classes
    AnyRef
  77. def openBufferedInputStream (): BufferedInputStream

    Opens a FileInputStream for the specified file, providing better error messages than simply calling new FileInputStream(file).

    Opens a FileInputStream for the specified file, providing better error messages than simply calling new FileInputStream(file).

    At the end of the method either the stream will be successfully opened, or an exception will have been thrown.

    An exception is thrown if the file does not exist. An exception is thrown if the file object exists but is a directory. An exception is thrown if the file exists but cannot be read.

    returns

    a new FileInputStream for the specified file

  78. def openBufferedOutputStream (): BufferedOutputStream

    Opens a FileOutputStream for the specified file, checking and creating the parent directory if it does not exist.

    Opens a FileOutputStream for the specified file, checking and creating the parent directory if it does not exist.

    At the end of the method either the stream will be successfully opened, or an exception will have been thrown.

    The parent directory will be created if it does not exist. The file will be created if it does not exist. An exception is thrown if the file object exists but is a directory. An exception is thrown if the file exists but cannot be written to. An exception is thrown if the parent directory cannot be created.

    returns

    a new FileOutputStream for the specified file

  79. def openInputStream (): InputStream

    Opens a FileInputStream for the specified file, providing better error messages than simply calling new FileInputStream(file).

    Opens a FileInputStream for the specified file, providing better error messages than simply calling new FileInputStream(file).

    At the end of the method either the stream will be successfully opened, or an exception will have been thrown.

    An exception is thrown if the file does not exist. An exception is thrown if the file object exists but is a directory. An exception is thrown if the file exists but cannot be read.

    returns

    a new FileInputStream for the specified file

  80. def openOutputStream (): OutputStream

    Opens a FileOutputStream for the specified file, checking and creating the parent directory if it does not exist.

    Opens a FileOutputStream for the specified file, checking and creating the parent directory if it does not exist.

    At the end of the method either the stream will be successfully opened, or an exception will have been thrown.

    The parent directory will be created if it does not exist. The file will be created if it does not exist. An exception is thrown if the file object exists but is a directory. An exception is thrown if the file exists but cannot be written to. An exception is thrown if the parent directory cannot be created.

    returns

    a new FileOutputStream for the specified file

  81. def readLines (encoding: String = null): List[String]

    Reads the contents of a file line by line to a List of Strings.

    Reads the contents of a file line by line to a List of Strings. The file is always closed.

    encoding

    the encoding to use, null means platform default

    returns

    the list of Strings representing each line in the file, never null

  82. def readToByteArray (): Array[Byte]

    Reads the contents of a file into a byte array.

    Reads the contents of a file into a byte array. The file is always closed.

    returns

    the file contents, never null

  83. def readToString (encoding: String = null): String

    Reads the contents of a file into a String.

    Reads the contents of a file into a String. The file is always closed.

    encoding

    the encoding to use, null means platform default

    returns

    the file contents, never null

  84. def sizeOf : Long

    Returns the size of the specified file or directory.

    Returns the size of the specified file or directory. If the provided File is a regular file, then the file's length is returned. If the argument is a directory, then the size of the directory is calculated recursively. If a directory or subdirectory is security restricted, its size will not be included.

    returns

    the length of the file, or recursive size of the directory, provided (in bytes).

  85. def sizeOfDirectory : Long

    Counts the size of a directory recursively (sum of the length of all files).

    Counts the size of a directory recursively (sum of the length of all files).

    returns

    size of directory in bytes, 0 if directory is security restricted

  86. def synchronized [T0] (arg0: ⇒ T0): T0

    Attributes
    final
    Definition Classes
    AnyRef
  87. def toString (): String

    Definition Classes
    AnyRef → Any
  88. def touch (): Unit

    Implements the same behaviour as the "touch" utility on Unix.

    Implements the same behaviour as the "touch" utility on Unix. It creates a new file with size 0 or, if the file exists already, it is opened and closed without modifying it, but updating the file date and time.

    NOTE: As from v1.3, this method throws an IOException if the last modified date of the file cannot be set. Also, as from v1.3 this method creates parent directories if they do not exist.

  89. def wait (): Unit

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

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

    Attributes
    final
    Definition Classes
    AnyRef
    Annotations
    @throws()
  92. def waitFor (second: Int): Boolean

    Waits for NFS to propagate a file creation, imposing a timeout.

    Waits for NFS to propagate a file creation, imposing a timeout.

    This method repeatedly tests File#exists() until it returns true up to the maximum time specified in seconds.

    returns

    true if file exists

  93. def write (data: Array[Byte]): File

    Writes a byte array to a file creating the file if it does not exist.

    Writes a byte array to a file creating the file if it does not exist.

    NOTE: the parent directories of the file will be created if they do not exist.

    data

    the content to write to the file

    returns

    this file

  94. def write (data: CharSequence, encoding: String = null): File

    Writes a CharSequence to a file creating the file if it does not exist using the default encoding for the VM.

    Writes a CharSequence to a file creating the file if it does not exist using the default encoding for the VM.

    data

    the content to write to the file

    returns

    this file

  95. def writeLines [T] (lines: Seq[T], encoding: String, lineEnding: String): File

    Writes the toString() value of each item in a collection to the specified File line by line.

    Writes the toString() value of each item in a collection to the specified File line by line. The specified character encoding and the line ending will be used.

    NOTE: the parent directories of the file will be created if they do not exist.

    lines

    the lines to write, null entries produce blank lines

    encoding

    the encoding to use, null means platform default

    lineEnding

    the line separator to use, null is system default

    returns

    this file

Inherited from AnyRef

Inherited from Any