Get the basename (file name only) part of a path.
Get the basename (file name only) part of a path.
the file name portion, as a File
Copy the file to a target directory or file.
Copy the file to a target directory or file.
path to the target file or directory
the target file
Copy the file to a target directory or file.
Copy the file to a target directory or file.
path to the target file or directory
the target file
Recursively remove the directory specified by this object.
Recursively remove the directory specified by this object. This
method is conceptually equivalent to rm -r
on a Unix system.
Left(error)
or Right(total)
, where total
is the
number of files and directories actually deleted.
Get the directory name of the file.
Get the directory name of the file.
the directory portion, as a File
.
Split the file's path into directory (dirname) and file (basename) components.
Split the file's path into directory (dirname) and file (basename)
components. Analogous to Python's os.path.pathsplit()
function.
a (dirname, basename) tuple of File
objects.
Split this file's pathname into the directory name, basename, and extension pieces.
Split this file's pathname into the directory name, basename, and extension pieces.
a 3-tuple of (dirname, basename, extension)
Determine whether a directory is empty.
Determine whether a directory is empty. Only meaningful for a directory.
true if the directory is empty, false if not
List a directory recursively, returning File
objects for each file
(and subdirectory) found.
List a directory recursively, returning File
objects for each file
(and subdirectory) found. This method does lazy evaluation, instead
of calculating everything up-front, as walk()
does.
If topdown
is true
, a directory is generated before the entries
for any of its subdirectories (directories are generated top down).
If topdown
is false
, a directory directory is generated after
the entries for all of its subdirectories (directories are generated
bottom up).
true
to do a top-down traversal, false
otherwise.
a stream of File
objects for everything under
the directory.
Get the path of this file, relative to some other file.
Get the path of this file, relative to some other file.
the other file
the path of this file, relative to the other file.
Split this file's path into its constituent components.
Split this file's path into its constituent components. If the path is absolute, the first piece will have a file separator in the beginning. Examples:
Input | Output |
---|---|
"" | List("") |
"/" | List("/") |
"foo" | List("foo") |
"foo/bar" | List("foo", "bar") |
"." | List(".") |
"../foo" | List("..", "foo") |
"./foo" | List(".", "foo") |
"/foo/bar/baz" | List("/foo", "bar", "baz") |
"foo/bar/baz" | List("foo", "bar", "baz") |
"/foo" | List("/foo") |
the component pieces.
Similar to the Unix touch command, this function:
Similar to the Unix touch command, this function:
If the file corresponds to an existing directory, this method will return an error.
Set the last-modified time to this time, or to the current time if this parameter is negative.
Directory tree lister, adapted from Python's os.walk()
function.
Directory tree lister, adapted from Python's os.walk()
function.
NOTE: This function generates the entire directory tree in memory,
before returning. If you want a lazy generator, with optional filtering,
use the listRecursively()
method.
For each directory in the directory tree rooted at this object (including the directory itself, but excluding '.' and '..'), yields a 3-tuple.
dirpath, dirnames, filenames
dirpath
is a string, the path to the directory. dirnames
is a
list of the names of the subdirectories in dirpath
(excluding '.'
and '..'). filenames
is a list of the names of the non-directory
files in dirpath
. Note that the names in the lists are just names,
with no path components. To get a full path (which begins with this
directory) to a file or directory in dirpath
, use dirpath +
java.io.fileSeparator + name
, or use
grizzled.file.util.joinPath()
.
If topdown
is true
, the triplet for a directory is generated
before the triplets for any of its subdirectories (directories are
generated top down). If topdown
is false
, the triplet for a
directory is generated after the triples for all of its
subdirectories (directories are generated bottom up).
WARNING! This method does not grok symbolic links!
true
to do a top-down traversal, false
otherwise.
List of triplets, as described above.
A wrapper for
java.io.File
that provides additional methods. By importing the implicit conversion functions, you can use the methods in this class transparently from ajava.io.File
object.