Returns the absolute form of this abstract pathname.
Returns the absolute form of this abstract pathname.
Returns the absolute pathname string of this abstract pathname.
Returns the absolute pathname string of this abstract pathname.
Gets the base name, minus the full path and extension, from a full filename.
Gets the base name, minus the full path and extension, from a full filename.
This method will handle a file in either Unix or Windows format. The text after the last forward or backslash and before the last dot is returned.
a/b/c.txt --> c a.txt --> a a/b/c --> c a/b/c/ --> ""
The output will be the same irrespective of the machine that the code is running on.
the name of the file without the path, or an empty string if none exists
Returns the canonical form of this abstract pathname.
Returns the canonical form of this abstract pathname.
Returns the canonical pathname string of this abstract pathname.
Returns the canonical pathname string of this abstract pathname.
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();
the checksum object to be used, must not be null
the checksum specified, updated with the content of the file
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.
Cleans a directory without deleting it.
Concatenates a filename to a base path using normal command line style rules.
Concatenates a filename to a base path using normal command line style rules.
The effect is equivalent to resultant directory after changing directory to the first argument, followed by changing directory to the second argument.
The first argument is the base path, the second is the path to concatenate.
The returned path is always normalized via #normalize(String)
,
thus ..
is handled.
If pathToAdd
is absolute (has an absolute prefix), then
it will be normalized and returned.
Otherwise, the paths will be joined, normalized and returned.
The output will be the same on both Unix and Windows except for the separator character.
/foo/ + bar --> /foo/bar /foo + bar --> /foo/bar /foo + /bar --> /bar /foo + C:/bar --> C:/bar /foo + C:bar --> C:bar (*) /foo/a/ + ../bar --> foo/bar /foo/ + ../../bar --> null /foo/ + /bar --> /bar /foo/.. + /bar --> /bar /foo + bar/c.txt --> /foo/bar/c.txt /foo/c.txt + bar --> /foo/c.txt/bar (!)(*) Note that the Windows relative drive prefix is unreliable when used with this method. (!) Note that the first parameter must be a path. If it ends with a name, then the name will be built into the concatenated path. If this might be a problem, use
#getFullPath(String)
on the base path argument.
the filename (or path) to attach to the base
the concatenated path, or null if invalid
Concatenates a filename to a base path using normal command line style rules.
Concatenates a filename to a base path using normal command line style rules.
The effect is equivalent to resultant directory after changing directory to the first argument, followed by changing directory to the second argument.
The first argument is the base path, the second is the path to concatenate.
The returned path is always normalized via #normalize(String)
,
thus ..
is handled.
If pathToAdd
is absolute (has an absolute prefix), then
it will be normalized and returned.
Otherwise, the paths will be joined, normalized and returned.
The output will be the same on both Unix and Windows except for the separator character.
/foo/ + bar --> /foo/bar /foo + bar --> /foo/bar /foo + /bar --> /bar /foo + C:/bar --> C:/bar /foo + C:bar --> C:bar (*) /foo/a/ + ../bar --> foo/bar /foo/ + ../../bar --> null /foo/ + /bar --> /bar /foo/.. + /bar --> /bar /foo + bar/c.txt --> /foo/bar/c.txt /foo/c.txt + bar --> /foo/c.txt/bar (!)(*) Note that the Windows relative drive prefix is unreliable when used with this method. (!) Note that the first parameter must be a path. If it ends with a name, then the name will be built into the concatenated path. If this might be a problem, use
#getFullPath(String)
on the base path argument.
the filename (or path) to attach to the base
the concatenated path, or null if invalid
Concatenates a filename to a base path using normal command line style rules.
Concatenates a filename to a base path using normal command line style rules.
The effect is equivalent to resultant directory after changing directory to the first argument, followed by changing directory to the second argument.
The first argument is the base path, the second is the path to concatenate.
The returned path is always normalized via #normalize(String)
,
thus ..
is handled.
If pathToAdd
is absolute (has an absolute prefix), then
it will be normalized and returned.
Otherwise, the paths will be joined, normalized and returned.
The output will be the same on both Unix and Windows except for the separator character.
/foo/ + bar --> /foo/bar /foo + bar --> /foo/bar /foo + /bar --> /bar /foo + C:/bar --> C:/bar /foo + C:bar --> C:bar (*) /foo/a/ + ../bar --> foo/bar /foo/ + ../../bar --> null /foo/ + /bar --> /bar /foo/.. + /bar --> /bar /foo + bar/c.txt --> /foo/bar/c.txt /foo/c.txt + bar --> /foo/c.txt/bar (!)(*) Note that the Windows relative drive prefix is unreliable when used with this method. (!) Note that the first parameter must be a path. If it ends with a name, then the name will be built into the concatenated path. If this might be a problem, use
#getFullPath(String)
on the base path argument.
the filename (or path) to attach to the base
the concatenated path, or null if invalid
Concatenates a filename to a base path using normal command line style rules.
Concatenates a filename to a base path using normal command line style rules.
The effect is equivalent to resultant directory after changing directory to the first argument, followed by changing directory to the second argument.
The first argument is the base path, the second is the path to concatenate.
The returned path is always normalized via #normalize(String)
,
thus ..
is handled.
If pathToAdd
is absolute (has an absolute prefix), then
it will be normalized and returned.
Otherwise, the paths will be joined, normalized and returned.
The output will be the same on both Unix and Windows except for the separator character.
/foo/ + bar --> /foo/bar /foo + bar --> /foo/bar /foo + /bar --> /bar /foo + C:/bar --> C:/bar /foo + C:bar --> C:bar (*) /foo/a/ + ../bar --> foo/bar /foo/ + ../../bar --> null /foo/ + /bar --> /bar /foo/.. + /bar --> /bar /foo + bar/c.txt --> /foo/bar/c.txt /foo/c.txt + bar --> /foo/c.txt/bar (!)(*) Note that the Windows relative drive prefix is unreliable when used with this method. (!) Note that the first parameter must be a path. If it ends with a name, then the name will be built into the concatenated path. If this might be a problem, use
#getFullPath(String)
on the base path argument.
the filename (or path) to attach to the base
the concatenated path, or null if invalid
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
the second file
true if the content of the files are equal or they both don't exist, false otherwise
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.
the new directory, must not be null
the filter to apply, null means copy all directories and files
true if the file date of the copy should be the same as the original
the destination 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.
the new directory, must not be null
the filter to apply, null means copy all directories and files
the destination 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.
// only copy the directory structure copyDir(destDir, (file: File => file.isDirectory), false);
the new directory, must not be null
the filter to apply, null means copy all directories and files
true if the file date of the copy should be the same as the original
the destination 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.
// only copy the directory structure copyDir(destDir, (file: File => file.isDirectory), false);
the new directory, must not be null
the filter to apply, null means copy all directories and files
the destination 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.
the new directory, must not be null
should be the same as the original
the destination 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.
the new directory, must not be null
true if the file date of the copy should be the same as the original
the destination 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.
the new directory, must not be null
the destination 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.
the new directory, must not be null
the destination 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.
the directory to place the copy in, must not be null
the destination 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.
the directory to place the copy in, must not be null
the destination 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.
the new file, must not be null
the destination 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.
the new file, must not be null
true if the file date of the copy should be the same as the original
the destination 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.
the new file, must not be null
the destination 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.
the new file, must not be null
true if the file date of the copy should be the same as the original
the destination 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.
the directory to place the copy in, must not be null
the destination 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.
the directory to place the copy in, must not be null
true if the file date of the copy should be the same as the original
the destination 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.
the directory to place the copy in, must not be null
the destination 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.
the directory to place the copy in, must not be null
true if the file date of the copy should be the same as the original
the destination 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.
the InputStream
to copy bytes from, must not be null
this 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.
the URL
to copy bytes from, must not be null
the number of milliseconds until this method will
timeout if no data could be read from the source
this 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.
the URL
to copy bytes from, must not be null
the number of milliseconds until this method will
timeout if no data could be read from the source
this 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.
the URL
to copy bytes from, must not be null
this 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.
the URL
to copy bytes from, must not be null
this file
Deletes a directory recursively.
Deletes a directory recursively.
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:
true
if the file or directory was deleted, otherwise
false
Gets the full path from a full filename, which is the prefix + path.
Gets the full path from a full filename, which is the prefix + path.
This method will handle a file in either Unix or Windows format. The method is entirely text based, and returns the text before and including the last forward or backslash.
C:\a\b\c.txt --> C:\a\b\ ~/a/b/c.txt --> ~/a/b/ a.txt --> "" a/b/c --> a/b/ a/b/c/ --> a/b/c/ C: --> C: C:\ --> C:\ ~ --> ~/ ~/ --> ~/ ~user --> ~user/ ~user/ --> ~user/
The output will be the same irrespective of the machine that the code is running on.
the path of the file, an empty string if none exists, null if invalid
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.
a human-readable display value (includes units - GB, MB, KB or bytes)
Applies a function f to all line.
Applies a function f to all line.
function
the encoding to use, null
means platform default
Checks whether two filenames are equal, optionally normalizing and providing control over the case-sensitivity.
Checks whether two filenames are equal, optionally normalizing and providing control over the case-sensitivity.
the second filename to query, may be null
whether to normalize the filenames
what case sensitivity rule to use, null means case-sensitive
true if the filenames are equal, null equals null
Checks whether two filenames are equal after both have been normalized and using the case rules of the system.
Checks whether two filenames are equal after both have been normalized and using the case rules of the system.
Both filenames are first passed to #normalize(String)
.
The check is then performed case-sensitive on Unix and
case-insensitive on Windows.
the second filename to query, may be null
true if the filenames are equal, null equals null
Checks whether two filenames are equal after both have been normalized and using the case rules of the system.
Checks whether two filenames are equal after both have been normalized and using the case rules of the system.
Both filenames are first passed to #normalize(String)
.
The check is then performed case-sensitive on Unix and
case-insensitive on Windows.
the second filename to query, may be null
true if the filenames are equal, null equals null
Gets the extension of a filename.
Gets the extension of a filename.
This method returns the textual part of the filename after the last dot. There must be no directory separator after the dot.
foo.txt --> "txt" a/b/c.jpg --> "jpg" a/b.txt/c --> "" a/b/c --> ""
The output will be the same irrespective of the machine that the code is running on.
the extension of the file or an empty string if none exists or null
if the filename is null
.
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:
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.
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.
this file
Returns the number of unallocated bytes in the partition named by this abstract path name.
Returns the number of unallocated bytes in the partition named by this abstract path name.
Gets the prefix from a full filename, such as C:/
or ~/
.
Gets the prefix from a full filename, such as C:/
or ~/
.
This method will handle a file in either Unix or Windows format. The prefix includes the first slash in the full filename where applicable.
Windows: a\b\c.txt --> "" --> relative \a\b\c.txt --> "\" --> current drive absolute C:a\b\c.txt --> "C:" --> drive relative C:\a\b\c.txt --> "C:\" --> absolute \\server\a\b\c.txt --> "\\server\" --> UNC Unix: a/b/c.txt --> "" --> relative /a/b/c.txt --> "/" --> absolute ~/a/b/c.txt --> "~/" --> current user ~ --> "~/" --> current user (slash added) ~user/a/b/c.txt --> "~user/" --> named user ~user --> "~user/" --> named user (slash added)
The output will be the same irrespective of the machine that the code is running on. ie. both Unix and Windows prefixes are matched regardless.
the prefix of the file, null if invalid
Returns the index of the last extension separator character, which is a dot.
Returns the index of the last extension separator character, which is a dot.
This method also checks that there is no directory separator after the last dot.
To do this it uses #indexOfLastSeparator(String)
which will
handle a file in either Unix or Windows format.
The output will be the same irrespective of the machine that the code is running on.
the index of the last separator character, or -1 if there is no such character
Returns the index of the last directory separator character.
Returns the index of the last directory separator character.
This method will handle a file in either Unix or Windows format. The position of the last forward or backslash is returned.
The output will be the same irrespective of the machine that the code is running on.
the index of the last separator character, or -1 if there is no such character
Checks whether the extension of the filename is one of those specified.
Checks whether the extension of the filename is one of those specified.
This method obtains the extension as the textual part of the filename after the last dot. There must be no directory separator after the dot. The extension check is case-sensitive on all platforms.
the extensions to check for, null checks for no extension
true if the filename is one of the extensions
Checks whether the extension of the filename is that specified.
Checks whether the extension of the filename is that specified.
This method obtains the extension as the textual part of the filename after the last dot. There must be no directory separator after the dot. The extension check is case-sensitive on all platforms.
the extension to check for, null or empty checks for no extension
true if the filename has the specified extension
Tests if the specified File
is newer than the specified
time reference.
Tests if the specified File
is newer than the specified
time reference.
the time reference measured in milliseconds since the epoch (00:00:00 GMT, January 1, 1970)
true if the File
exists and has been modified after
the given time reference.
Tests if the specified File
is newer than the specified
Date
.
Tests if the specified File
is newer than the specified
Date
.
the date reference, must not be null
true if the File
exists and has been modified
after the given Date
.
Tests if the specified File
is newer than the reference
File
.
Tests if the specified File
is newer than the reference
File
.
true if the File
exists and has been modified more
recently than the reference File
Tests if the specified File
is older than the specified
time reference.
Tests if the specified File
is older than the specified
time reference.
the time reference measured in milliseconds since the epoch (00:00:00 GMT, January 1, 1970)
true if the File
exists and has been modified before
the given time reference.
Tests if the specified File
is older than the specified
Date
.
Tests if the specified File
is older than the specified
Date
.
the date reference, must not be null
true if the File
exists and has been modified
before the given Date
.
Tests if the specified File
is older than the reference
File
.
Tests if the specified File
is older than the reference
File
.
the File
of which the modification date
is used, must not be null
true if the File
exists and has been modified before
the reference File
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.
true if the file is a Symbolic Link
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.
the encoding to use, null
means platform default
an Iterator of the lines in the file, never null
Finds files within a given directory which match an array of extensions.
Finds files within a given directory which match an array of extensions.
an array of extensions, ex. {"java","xml"}. If this
parameter is null
, all files are returned.
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.
an array of extensions, ex. {"java","xml"}. If this
Finds files within a given directory and its subdirectories.
Finds files within a given directory and its subdirectories.
Moves a directory to another directory.
Moves a directory to another directory. create the destination directory
the destination file
the destination directory
Moves a directory to another directory.
Moves a directory to another directory. create the destination directory
the destination directory
Moves a directory.
Moves a directory.
When the destination directory is on another file system, do a "copy and delete".
the destination directory
Moves a directory.
Moves a directory.
When the destination directory is on another file system, do a "copy and delete".
the destination directory
the destination directory
Moves a directory to another directory.
Moves a directory to another directory.
If true
create the destination directory,
otherwise if false
throw an IOException
the destination directory
Moves a directory to another directory.
Moves a directory to another directory.
the destination file
If true
create the destination directory,
otherwise if false
throw an IOException
the destination directory
Moves a file.
Moves a file.
When the destination file is on another file system, do a "copy and delete".
the destination file
the destination file
Moves a file.
Moves a file.
When the destination file is on another file system, do a "copy and delete".
the destination file
the destination file
Moves a file to a directory.
Moves a file to a directory. create the destination directory.
the destination file
Moves a file to a directory.
Moves a file to a directory. create the destination directory.
the destination file
the destination file
Moves a file to a directory.
Moves a file to a directory.
If true
create the destination directory,
otherwise if false
throw an IOException
the destination file
Moves a file to a directory.
Moves a file to a directory.
the destination file
If true
create the destination directory,
otherwise if false
throw an IOException
the destination 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".
the destination directory
the destination file or directory
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".
the destination directory
the destination file or directory
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".
the destination directory
If true
create the destination directory,
otherwise if false
throw an IOException
the destination file or directory
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".
the destination directory
If true
create the destination directory,
otherwise if false
throw an IOException
the destination file or directory
Returns the name of the file or directory denoted by this abstract pathname.
Returns the name of the file or directory denoted by this abstract pathname.
Normalizes a path, removing double and single dot path steps.
Normalizes a path, removing double and single dot path steps.
This method normalizes a path to a standard format. The input may contain separators in either Unix or Windows format. The output will contain separators in the format specified.
A trailing slash will be retained.
A double slash will be merged to a single slash (but UNC names are handled).
A single dot path segment will be removed.
A double dot will cause that path segment and the one before to be removed.
If the double dot has no parent path segment to work with, null
is returned.
The output will be the same on both Unix and Windows except for the separator character.
/foo// --> /foo/ /foo/./ --> /foo/ /foo/../bar --> /bar /foo/../bar/ --> /bar/ /foo/../bar/../baz --> /baz //foo//./bar --> /foo/bar /../ --> null ../foo --> null foo/bar/.. --> foo/ foo/../../bar --> null foo/../bar --> bar //server/foo/../bar --> //server/bar //server/../bar --> null C:\foo\..\bar --> C:\bar C:\..\bar --> null ~/foo/../bar/ --> ~/bar/ ~/../bar --> nullThe output will be the same on both Unix and Windows including the separator character.
the normalized filename, or null if invalid
Normalizes a path, removing double and single dot path steps.
Normalizes a path, removing double and single dot path steps.
This method normalizes a path to a standard format. The input may contain separators in either Unix or Windows format. The output will contain separators in the format specified.
A trailing slash will be retained.
A double slash will be merged to a single slash (but UNC names are handled).
A single dot path segment will be removed.
A double dot will cause that path segment and the one before to be removed.
If the double dot has no parent path segment to work with, null
is returned.
The output will be the same on both Unix and Windows except for the separator character.
/foo// --> /foo/ /foo/./ --> /foo/ /foo/../bar --> /bar /foo/../bar/ --> /bar/ /foo/../bar/../baz --> /baz //foo//./bar --> /foo/bar /../ --> null ../foo --> null foo/bar/.. --> foo/ foo/../../bar --> null foo/../bar --> bar //server/foo/../bar --> //server/bar //server/../bar --> null C:\foo\..\bar --> C:\bar C:\..\bar --> null ~/foo/../bar/ --> ~/bar/ ~/../bar --> nullThe output will be the same on both Unix and Windows including the separator character.
true
if a unix separator should
be used or false
if a windows separator should be used.
the normalized filename, or null if invalid
Tests whether the file or directory denoted by this abstract pathname not exists.
Tests whether the file or directory denoted by this abstract pathname not exists.
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.
a new FileInputStream
for the specified file
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.
a new FileOutputStream
for the specified file
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.
a new FileInputStream
for the specified file
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.
a new FileOutputStream
for the specified file
Returns the abstract pathname of this abstract pathname's parent, or null if this pathname does not name a parent directory.
Returns the abstract pathname of this abstract pathname's parent, or null if this pathname does not name a parent directory.
Returns the pathname string of this abstract pathname's parent, or null if this pathname does not name a parent directory.
Returns the pathname string of this abstract pathname's parent, or null if this pathname does not name a parent directory.
Converts this abstract pathname into a pathname string.
Converts this abstract pathname into a pathname string.
Checks a filename to see if it matches the specified wildcard matcher allowing control over case-sensitivity.
Checks a filename to see if it matches the specified wildcard matcher allowing control over case-sensitivity.
The wildcard matcher uses the characters '?' and '*' to represent a single or multiple (zero or more) wildcard characters. N.B. the sequence "*?" does not work properly at present in match strings.
what case sensitivity rule to use, null means case-sensitive
true if the filename matches the wilcard string
Checks a filename to see if it matches the specified wildcard matcher using the case rules of the system.
Checks a filename to see if it matches the specified wildcard matcher using the case rules of the system.
The wildcard matcher uses the characters '?' and '*' to represent a single or multiple (zero or more) wildcard characters. This is the same as often found on Dos/Unix command lines. The check is case-sensitive on Unix and case-insensitive on Windows.
wildcardMatch("c.txt", "*.txt") --> true wildcardMatch("c.txt", "*.jpg") --> false wildcardMatch("c.txt", "*.???") --> true wildcardMatch("c.txt", "*.????") --> falseN.B. the sequence "*?" does not work properly at present in match strings.
the wildcard string to match against
true if the filename matches the wilcard string
Returns the length of the filename prefix, such as C:/
or ~/
.
Returns the length of the filename prefix, such as C:/
or ~/
.
This method will handle a file in either Unix or Windows format.
The prefix length includes the first slash in the full filename if applicable. Thus, it is possible that the length returned is greater than the length of the input string.
Windows: a\b\c.txt --> "" --> relative \a\b\c.txt --> "\" --> current drive absolute C:a\b\c.txt --> "C:" --> drive relative C:\a\b\c.txt --> "C:\" --> absolute \\server\a\b\c.txt --> "\\server\" --> UNC Unix: a/b/c.txt --> "" --> relative /a/b/c.txt --> "/" --> absolute ~/a/b/c.txt --> "~/" --> current user ~ --> "~/" --> current user (slash added) ~user/a/b/c.txt --> "~user/" --> named user ~user --> "~user/" --> named user (slash added)
The output will be the same irrespective of the machine that the code is running on. ie. both Unix and Windows prefixes are matched regardless.
the length of the prefix, -1 if invalid or null
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.
the encoding to use, null
means platform default
the list of Strings representing each line in the file, never null
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.
the file contents, never null
Reads the contents of a file into a String.
Reads the contents of a file into a String. The file is always closed.
the encoding to use, null
means platform default
the file contents, never null
Removes the extension from a filename.
Removes the extension from a filename.
This method returns the textual part of the filename before the last dot. There must be no directory separator after the dot.
foo.txt --> foo a\b\c.jpg --> a\b\c a\b\c --> a\b\c a.b\c --> a.b\c
The output will be the same irrespective of the machine that the code is running on.
the filename minus the extension
Converts all separators to the Windows separator of backslash.
Converts all separators to the Windows separator of backslash.
the updated path
Converts all separators to the Unix separator of forward slash.
Converts all separators to the Unix separator of forward slash.
the updated path
Converts all separators to the Windows separator of backslash.
Converts all separators to the Windows separator of backslash.
the updated path
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.
the length of the file, or recursive size of the directory, provided (in bytes).
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).
size of directory in bytes, 0 if directory is security restricted
Returns the size of the partition named by this abstract pathname.
Returns the size of the partition named by this abstract pathname.
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.
Returns the number of bytes available to this virtual machine on the partition named by this abstract pathname.
Returns the number of bytes available to this virtual machine on the partition named by this abstract pathname.
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.
true if file exists
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.
the content to write to the file
this 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.
the content to write to the file
this 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.
the lines to write, null
entries produce blank lines
the encoding to use, null
means platform default
the line separator to use, null
is system default
this file