Modifier and Type | Field and Description |
---|---|
static DirectoryStream.Filter |
ACCEPT_ALL_FILTER |
static int |
BUFFER_SIZE |
private OctopusEngine |
octopusEngine |
Constructor and Description |
---|
FilesEngine(OctopusEngine octopusEngine) |
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.
|
private Adaptor |
getAdaptor(Path path) |
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 owner,
String group)
Updates the file owner and group.
|
void |
setPosixFilePermissions(Path path,
Set<PosixFilePermission> permissions)
Sets a file's POSIX permissions.
|
public static DirectoryStream.Filter ACCEPT_ALL_FILTER
public static final int BUFFER_SIZE
private final OctopusEngine octopusEngine
public FilesEngine(OctopusEngine octopusEngine)
public Path newPath(URI location) throws OctopusException
newPath
in interface Files
OctopusException
public boolean isDirectory(Path path) throws OctopusException
Files
isDirectory
in interface Files
OctopusException
public SeekableByteChannel newByteChannel(Path path, OpenOption... options) throws OctopusException
Files
newByteChannel
in interface Files
OctopusException
public DirectoryStream<Path> newDirectoryStream(Path dir) throws OctopusException
Files
newDirectoryStream
in interface Files
OctopusException
public DirectoryStream<PathAttributes> newAttributesDirectoryStream(Path dir) throws OctopusException
Files
newAttributesDirectoryStream
in interface Files
OctopusException
public Path newPath(Properties properties, Credentials credentials, URI location) throws OctopusException
newPath
in interface Files
OctopusException
public Path copy(Path source, Path target, CopyOption... options) throws OctopusException
Files
copy
in interface Files
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 occurspublic Path createDirectories(Path dir, Set<PosixFilePermission> permissions) throws OctopusException
Files
createDirectories
in interface Files
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
public Path createDirectory(Path dir, Set<PosixFilePermission> permissions) throws OctopusException
Files
createDirectory
in interface Files
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 existpublic Path createFile(Path path, Set<PosixFilePermission> permissions) throws OctopusException
Files
createFile
in interface Files
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 existpublic Path createSymbolicLink(Path link, Path target) throws OctopusException
Files
createSymbolicLink
in interface Files
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 occurspublic void delete(Path path, DeleteOption... options) throws OctopusException
Files
delete
in interface Files
OctopusException
public boolean deleteIfExists(Path path, DeleteOption... options) throws OctopusException
Files
deleteIfExists
in interface Files
OctopusException
public boolean exists(Path path) throws OctopusException
Files
exists
in interface Files
OctopusException
private Adaptor getAdaptor(Path path) throws OctopusException
OctopusException
public Path move(Path source, Path target, CopyOption... options) throws OctopusException
Files
move
in interface Files
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 occurspublic DirectoryStream<Path> newDirectoryStream(Path dir, DirectoryStream.Filter filter) throws OctopusException
Files
newDirectoryStream
in interface Files
OctopusException
public DirectoryStream<PathAttributes> newAttributesDirectoryStream(Path dir, DirectoryStream.Filter filter) throws OctopusException
Files
newAttributesDirectoryStream
in interface Files
OctopusException
public InputStream newInputStream(Path path) throws OctopusException
Files
newInputStream
in interface Files
OctopusException
public OutputStream newOutputStream(Path path, OpenOption... options) throws OctopusException
Files
newOutputStream
in interface Files
OctopusException
public SeekableByteChannel newByteChannel(Path path, Set<PosixFilePermission> permissions, OpenOption... options) throws OctopusException
Files
newByteChannel
in interface Files
OctopusException
public FileAttributes readAttributes(Path path) throws OctopusException
Files
readAttributes
in interface Files
OctopusException
public Path readSymbolicLink(Path link) throws OctopusException
Files
readSymbolicLink
in interface Files
OctopusException
public void setOwner(Path path, String owner, String group) throws OctopusException
Files
setOwner
in interface Files
OctopusException
public void setPosixFilePermissions(Path path, Set<PosixFilePermission> permissions) throws OctopusException
Files
setPosixFilePermissions
in interface Files
OctopusException
public void setFileTimes(Path path, long lastModifiedTime, long lastAccessTime, long createTime) throws OctopusException
Files
setFileTimes
in interface Files
OctopusException
public void setAcl(Path path, List<AclEntry> acl) throws OctopusException
Files
setAcl
in interface Files
OctopusException