public interface FileSystem
Path
points to a location (existing or not)
on a FileSystem
.
A FileSystem
is rarely used directly. One
only needs to be creating a new path
scheme, in which case a FileSystemProvider
must also be implemented.
Modifier and Type | Method and Description |
---|---|
InputStream |
concat(List<Path> paths,
boolean ignoreNonExistent)
Returns an input stream consisting of the given list of paths concatenated together.
|
Path |
createDirectories(Path path)
Creates the directory identified by the given path,
creating any necessary parent directories.
|
Path |
createDirectory(Path path)
Creates the directory identified by the given path.
|
boolean |
createNewFile(Path path)
Creates the file identified by the given path, if
it doesn't already exist.
|
void |
delete(Path path,
boolean recursively)
Deletes the file or directory identified by the specified
path.
|
boolean |
exists(Path path)
Indicates whether the specified path represents an
existing file or directory.
|
PathDetails |
getDetails(Path path)
Returns metadata associated with the specified path.
|
String |
getFileSystemType(Path path)
Returns an identifier for the filesystem type.
|
Object |
getImplementation() |
long |
getLength(Path path)
Returns the length of the file represented by the given path.
|
FileSystemProvider |
getProvider()
Gets the provider for the path scheme associated
with the file system.
|
SplitIterator |
getSplits(Path path,
SplitOptions options)
Computes data splits over the specified file.
|
boolean |
isCreatable(Path path)
Indicates whether the specified path can be created.
|
boolean |
isDirectory(Path path)
Indicates whether the specified path represents a directory.
|
boolean |
isFile(Path path)
Indicates whether the specified path represents a file.
|
boolean |
isHidden(Path path)
Indicates whether the associated path is hidden by the file system.
|
boolean |
isReadable(Path path)
Indicates whether the specified path can be read.
|
boolean |
isWritable(Path path)
Indicates whether the specified path can be written.
|
List<PathDetails> |
listDirectory(Path path,
DirectoryFilter filter)
Gets the contents of the specified directory, applying
a filter.
|
List<PathDetails> |
matchPaths(String pattern)
Gets all paths which match the given pattern.
|
boolean |
move(FileSystem fromFS,
Path from,
Path to)
Moves a file or directory from one location to
another if possible.
|
FileChannel |
newFileChannel(Path path)
Opens the specified file for random access.
|
InputStream |
newInputStream(Path path)
Opens the specified file for reading.
|
OutputStream |
newOutputStream(Path path,
WriteMode mode)
Opens the specified file for writing.
|
boolean |
supportsConcat()
Returns whether this filesystem supports the
concat
method. |
boolean |
supportsDirectories()
Indicates whether the file system supports
directories.
|
boolean |
supportsRandomAccess()
Indicates whether the file system supports
random access to files.
|
String getFileSystemType(Path path)
path
- the pathFileSystemProvider getProvider()
boolean supportsRandomAccess()
If a file system does not support random access,
calling FileClient.newFileChannel(Path)
will
raise an error for paths referring to the file
system.
true
if random access is supported,
false
otherwise.boolean supportsDirectories()
true
if directories are supported,
false
otherwise.List<PathDetails> matchPaths(String pattern) throws IOException
pattern
- the file pattern to useIOException
- if I/O errors occurIllegalArgumentException
- if the pattern is not
prefixed with a scheme supported by the providerPath createDirectories(Path path) throws IOException
path
- the directory to createIOException
- if I/O errors occurIllegalArgumentException
- if the path is not
is not for a scheme supported by the providerPath createDirectory(Path path) throws IOException
createDirectories(Path)
if nonexistent
parents need to be created.path
- the directory to createIOException
- if I/O errors occur or if the
parent directory does not existIllegalArgumentException
- if the path is not
is not for a scheme supported by the providerboolean createNewFile(Path path) throws IOException
createDirectories(Path)
if nonexistent
parents need to be created.path
- the directory to createtrue
if the file was created,
false
if it already existed.IOException
- if I/O errors occur or if the
parent directory does not existIllegalArgumentException
- if the path is not
is not for a scheme supported by the providervoid delete(Path path, boolean recursively) throws IOException
path
- the file or directory to deleterecursively
- indicates whether deletes of directories
should recursively delete the contentsIOException
- if I/O errors occur or if the
path identifies a non-empty directory and a recursive
delete was not requestedIllegalArgumentException
- if the path is not
is not for a scheme supported by the providerboolean move(FileSystem fromFS, Path from, Path to) throws IOException
fromFS
- TODOfrom
- the source locationto
- the target locationIOException
- if I/O errors occurInputStream newInputStream(Path path) throws IOException
#listFiles(Path)
. The read starts at the first byte of the
(first) file. The returned stream is generally not buffered;
consult specific implementations for details.path
- the file or directory to readIOException
- if I/O errors occurFileNotFoundException
- if the specified path does not existIllegalArgumentException
- if the path is not
is not for a scheme supported by the providerOutputStream newOutputStream(Path path, WriteMode mode) throws IOException
CREATE_NEW
, an
error is raised.OVERWRITE
, the
existing file is replaced with the byte written to the resulting
stream.APPEND
, the resulting
stream is positioned after the last byte of the existing file.The returned stream is generally not buffered; consult specific implementations for details.
path
- the file to writemode
- how to handle writes to existing filesIOException
- if I/O errors occur or if the target is
a directoryIllegalArgumentException
- if the path is not
is not for a scheme supported by the providerFileChannel newFileChannel(Path path) throws IOException
path
- the file or directory to readIOException
- if I/O errors occurFileNotFoundException
- if the specified path does not existIllegalArgumentException
- if the path is not
is not for a scheme supported by the providerboolean exists(Path path) throws IOException
path
- the path to testtrue
the path exists, false
otherwise.IOException
- if I/O errors occurIllegalArgumentException
- if the path is not
is not for a scheme supported by the providerPathDetails getDetails(Path path) throws IOException
path
- the path for which to get metadatanull
if it does not exist.IOException
- if I/O errors occurlong getLength(Path path) throws IOException
path
- the path to testIOException
- if I/O errors occurboolean isDirectory(Path path) throws IOException
path
- the path to testtrue
the path represents a directory,IOException
- if I/O errors occurIllegalArgumentException
- if the path is not
is not for a scheme supported by the providerboolean isFile(Path path) throws IOException
path
- the path to testtrue
the path represents a file,IOException
- if I/O errors occurIllegalArgumentException
- if the path is not
is not for a scheme supported by the providerboolean isReadable(Path path) throws IOException
path
- the path to testtrue
the path represents a readable
file or directory, false
otherwise.IOException
- if I/O errors occurIllegalArgumentException
- if the path is not
is not for a scheme supported by the providerboolean isWritable(Path path) throws IOException
path
- the path to testtrue
the path represents a readable
file or directory, false
otherwise.IOException
- if I/O errors occurIllegalArgumentException
- if the path is not
is not for a scheme supported by the providerboolean isCreatable(Path path) throws IOException
path
- the path to testtrue
the path represents a nonexistent
file or directory which could be created, false
otherwise.IOException
- if I/O errors occurIllegalArgumentException
- if the path is not
is not for a scheme supported by the providerboolean isHidden(Path path) throws IOException
path
- the path to testtrue
if the path is hidden,
false
otherwise.IOException
- if I/O errors occurIllegalArgumentException
- if the path is not
is not for a scheme supported by the providerList<PathDetails> listDirectory(Path path, DirectoryFilter filter) throws IOException
path
- the directory for which to get a filtered content listfilter
- a filter to apply to the contentsIOException
- if I/O errors occur or if the
path identifies a fileIllegalArgumentException
- if the path is not
is not for a scheme supported by the providerSplitIterator getSplits(Path path, SplitOptions options) throws IOException
If a provider can provide locality information, it should, as this can be used to guide distributed execution.
path
- the file for which to get splitsoptions
- configuration for the process
of dividing the fileIOException
- if an I/O error occursboolean supportsConcat()
concat
method.InputStream concat(List<Path> paths, boolean ignoreNonExistent) throws IOException
paths
- the list of pathsignoreNonExistent
- whether to skip non-existent filesIOException
UnsupportedOperationException
- If this filesystem does not support concatenation.Object getImplementation()
Copyright © 2016 Actian Corporation. All rights reserved.