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
A Success
containing the target file, or Failure(exception)
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
A Success
containing the target file, or Failure(exception)
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.
Failure(exception)
or Success(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.
A version of java.io.File.exists
that returns a Try
, this
method tests the existence of the file.
A version of java.io.File.exists
that returns a Try
, this
method tests the existence of the file.
Success(true)
if the file exists, and
Failure(FileDoesNotExistException)
if it does not.
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.
Success(true)
on success, Failure(exception)
on error.
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.