public interface Files
Modifier and Type | Method and Description |
---|---|
Path |
copy(Path source,
Path target,
CopyOption... options)
Copy a file to a target file.
|
Path |
createDirectories(Path dir,
Set<PosixFilePermission> permissions)
Creates a directory by creating all nonexistent parent directories first.
|
Path |
createDirectory(Path dir,
Set<PosixFilePermission> permissions)
Creates a new directory.
|
Path |
createFile(Path path,
Set<PosixFilePermission> permissions)
Creates a new and empty file, failing if the file already exists.
|
Path |
createSymbolicLink(Path link,
Path target)
Creates a symbolic link to a target (optional operation).
|
void |
delete(Path path,
DeleteOption... options)
Deletes a file.
|
boolean |
deleteIfExists(Path path,
DeleteOption... options)
Deletes a file if it exists.
|
boolean |
exists(Path path)
Tests whether a file exists.
|
boolean |
isDirectory(Path path)
Tests whether a file is a directory.
|
Path |
move(Path source,
Path target,
CopyOption... options)
Move or rename a file to a target file.
|
DirectoryStream<PathAttributes> |
newAttributesDirectoryStream(Path dir)
Opens a directory, returning a DirectoryStream to iterate over all
entries in the directory.
|
DirectoryStream<PathAttributes> |
newAttributesDirectoryStream(Path dir,
DirectoryStream.Filter filter)
Opens a directory, returning a DirectoryStream to iterate over the
entries in the directory.
|
SeekableByteChannel |
newByteChannel(Path path,
OpenOption... options)
Opens or creates a file, returning a seekable byte channel to access the
file.
|
SeekableByteChannel |
newByteChannel(Path path,
Set<PosixFilePermission> permissions,
OpenOption... options)
Opens or creates a file, returning a seekable byte channel to access the
file.
|
DirectoryStream<Path> |
newDirectoryStream(Path dir)
Opens a directory, returning a DirectoryStream to iterate over all
entries in the directory.
|
DirectoryStream<Path> |
newDirectoryStream(Path dir,
DirectoryStream.Filter filter)
Opens a directory, returning a DirectoryStream to iterate over the
entries in the directory.
|
InputStream |
newInputStream(Path path)
Opens a file, returning an input stream to read from the file.
|
OutputStream |
newOutputStream(Path path,
OpenOption... options)
Opens or creates a file, returning an output stream that may be used to
write bytes to the file.
|
Path |
newPath(Properties properties,
Credentials credentials,
URI location) |
Path |
newPath(URI location) |
FileAttributes |
readAttributes(Path path)
Reads a file's attributes.
|
Path |
readSymbolicLink(Path link)
Reads the target of a symbolic link (optional operation).
|
void |
setAcl(Path path,
List<AclEntry> acl)
Updates (replace) the access control list.
|
void |
setFileTimes(Path path,
long lastModifiedTime,
long lastAccessTime,
long createTime)
Updates a file's last modified, last access, and create time attribute.
|
void |
setOwner(Path path,
String user,
String group)
Updates the file owner and group.
|
void |
setPosixFilePermissions(Path path,
Set<PosixFilePermission> permissions)
Sets a file's POSIX permissions.
|
Path newPath(URI location) throws OctopusException
OctopusException
Path newPath(Properties properties, Credentials credentials, URI location) throws OctopusException
OctopusException
Path copy(Path source, Path target, CopyOption... options) throws OctopusException
UnsupportedOperationException
- if the array contains a copy option that is not supportedFileAlreadyExistsException
- if the target file exists but cannot be replaced because the
REPLACE_EXISTING
option is not specified (optional
specific exception)DirectoryNotEmptyException
- the REPLACE_EXISTING
option is specified but the file
cannot be replaced because it is a non-empty directory
(optional specific exception)OctopusException
- if an I/O error occursPath createDirectories(Path dir, Set<PosixFilePermission> permissions) throws OctopusException
UnsupportedOperationException
- if the given Permissions cannot be set when the file is
createdFileAlreadyExistsException
- if dir
exists but is not a directory (optional
specific exception)OctopusException
Path createDirectory(Path dir, Set<PosixFilePermission> permissions) throws OctopusException
UnsupportedOperationException
- if the given Permissions cannot be set when the file is
createdFileAlreadyExistsException
- if a directory could not otherwise be created because a file
of that name already exists (optional specific
exception)OctopusException
- if an I/O error occurs or the parent directory does not existPath createFile(Path path, Set<PosixFilePermission> permissions) throws OctopusException
UnsupportedOperationException
- if the given Permissions cannot be set when the file is
createdFileAlreadyExistsException
- if a file of that name already exists (optional specific
exception)OctopusException
- if an I/O error occurs or the parent directory does not existPath createSymbolicLink(Path link, Path target) throws OctopusException
UnsupportedOperationException
- if the adaptor used does not support symbolic links.FileAlreadyExistsException
- if a file with the name already exists (optional specific
exception)OctopusException
- if an I/O error occursvoid delete(Path path, DeleteOption... options) throws OctopusException
OctopusException
boolean deleteIfExists(Path path, DeleteOption... options) throws OctopusException
OctopusException
boolean exists(Path path) throws OctopusException
OctopusException
boolean isDirectory(Path path) throws OctopusException
OctopusException
Path move(Path source, Path target, CopyOption... options) throws OctopusException
UnsupportedOperationException
- if the array contains a copy option that is not supportedFileAlreadyExistsException
- if the target file exists but cannot be replaced because the
REPLACE_EXISTING
option is not specified (optional
specific exception)DirectoryNotEmptyException
- the REPLACE_EXISTING
option is specified but the file
cannot be replaced because it is a non-empty directory
(optional specific exception)OctopusException
- if an I/O error occursDirectoryStream<Path> newDirectoryStream(Path dir) throws OctopusException
OctopusException
DirectoryStream<Path> newDirectoryStream(Path dir, DirectoryStream.Filter filter) throws OctopusException
OctopusException
DirectoryStream<PathAttributes> newAttributesDirectoryStream(Path dir) throws OctopusException
OctopusException
DirectoryStream<PathAttributes> newAttributesDirectoryStream(Path dir, DirectoryStream.Filter filter) throws OctopusException
OctopusException
InputStream newInputStream(Path path) throws OctopusException
OctopusException
OutputStream newOutputStream(Path path, OpenOption... options) throws OctopusException
OctopusException
SeekableByteChannel newByteChannel(Path path, Set<PosixFilePermission> permissions, OpenOption... options) throws OctopusException
OctopusException
SeekableByteChannel newByteChannel(Path path, OpenOption... options) throws OctopusException
OctopusException
FileAttributes readAttributes(Path path) throws OctopusException
OctopusException
Path readSymbolicLink(Path link) throws OctopusException
OctopusException
void setOwner(Path path, String user, String group) throws OctopusException
OctopusException
void setPosixFilePermissions(Path path, Set<PosixFilePermission> permissions) throws OctopusException
OctopusException
void setFileTimes(Path path, long lastModifiedTime, long lastAccessTime, long createTime) throws OctopusException
OctopusException
void setAcl(Path path, List<AclEntry> acl) throws OctopusException
OctopusException