public class DesugarLinuxFileSystemProvider extends FileSystemProvider
FileSystemProvider for desugar support.| Modifier and Type | Method and Description |
|---|---|
void |
checkAccess(Path path,
AccessMode... modes)
Checks the existence, and optionally the accessibility, of a file.
|
void |
copy(Path source,
Path target,
CopyOption... options)
Copy a file to a target file.
|
static DesugarLinuxFileSystemProvider |
create() |
void |
createDirectory(Path dir,
FileAttribute<?>... attrs)
Creates a new directory.
|
void |
createLink(Path link,
Path existing)
Creates a new link (directory entry) for an existing file.
|
void |
createSymbolicLink(Path link,
Path target,
FileAttribute<?>... attrs)
Creates a symbolic link to a target.
|
void |
delete(Path path)
Deletes a file.
|
boolean |
deleteIfExists(Path path)
Deletes a file if it exists.
|
<V extends FileAttributeView> |
getFileAttributeView(Path path,
Class<V> type,
LinkOption... options)
Returns a file attribute view of a given type.
|
FileStore |
getFileStore(Path path)
Returns the
FileStore representing the file store where a file
is located. |
DesugarLinuxFileSystem |
getFileSystem(URI uri)
Returns an existing
FileSystem created by this provider. |
Path |
getPath(URI uri)
Return a
Path object by converting the given URI. |
String |
getScheme()
Returns the URI scheme that identifies this provider.
|
boolean |
isHidden(Path path)
Tells whether or not a file is considered hidden.
|
boolean |
isSameFile(Path path,
Path path2)
Tests if two paths locate the same file.
|
void |
move(Path source,
Path target,
CopyOption... options)
Move or rename a file to a target file.
|
AsynchronousFileChannel |
newAsynchronousFileChannel(Path path,
Set<? extends OpenOption> options,
ExecutorService executor,
FileAttribute<?>... attrs)
Opens or creates a file for reading and/or writing, returning an
asynchronous file channel to access the file.
|
DesugarSeekableByteChannel |
newByteChannel(Path path,
Set<? extends OpenOption> options,
FileAttribute<?>... attrs)
Opens or creates a file, returning a seekable byte channel to access the
file.
|
DirectoryStream<Path> |
newDirectoryStream(Path dir,
DirectoryStream.Filter<? super Path> filter)
Opens a directory, returning a
DirectoryStream to iterate over
the entries in the directory. |
FileChannel |
newFileChannel(Path path,
Set<? extends OpenOption> options,
FileAttribute<?>... attrs)
Opens or creates a file for reading and/or writing, returning a file
channel to access the file.
|
DesugarLinuxFileSystem |
newFileSystem(URI uri,
Map<String,?> env)
Constructs a new
FileSystem object identified by a URI. |
InputStream |
newInputStream(Path path,
OpenOption... options)
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.
|
<A extends BasicFileAttributes> |
readAttributes(Path path,
Class<A> type,
LinkOption... options)
Reads a file's attributes as a bulk operation.
|
Map<String,Object> |
readAttributes(Path path,
String attributes,
LinkOption... options)
Reads a set of file attributes as a bulk operation.
|
Path |
readSymbolicLink(Path link)
Reads the target of a symbolic link.
|
void |
setAttribute(Path path,
String attribute,
Object value,
LinkOption... options)
Sets the value of a file attribute.
|
installedProviders, newFileSystempublic static DesugarLinuxFileSystemProvider create()
public String getScheme()
FileSystemProvidergetScheme in class FileSystemProviderpublic DesugarLinuxFileSystem newFileSystem(URI uri, Map<String,?> env)
FileSystemProviderFileSystem object identified by a URI. This
method is invoked by the FileSystems.newFileSystem(URI,Map)
method to open a new file system identified by a URI.
The uri parameter is an absolute, hierarchical URI, with a
scheme equal (without regard to case) to the scheme supported by this
provider. The exact form of the URI is highly provider dependent. The
env parameter is a map of provider specific properties to configure
the file system.
This method throws FileSystemAlreadyExistsException if the
file system already exists because it was previously created by an
invocation of this method. Once a file system is closed it is provider-dependent if the
provider allows a new file system to be created with the same URI as a
file system it previously created.
newFileSystem in class FileSystemProvideruri - URI referenceenv - A map of provider specific properties to configure the file system;
may be emptypublic final DesugarLinuxFileSystem getFileSystem(URI uri)
FileSystemProviderFileSystem created by this provider.
This method returns a reference to a FileSystem that was
created by invoking the newFileSystem(URI,Map)
method. File systems created the newFileSystem(Path,Map) method are not returned by this method.
The file system is identified by its URI. Its exact form
is highly provider dependent. In the case of the default provider the URI's
path component is "/" and the authority, query and fragment components
are undefined (Undefined components are represented by null).
Once a file system created by this provider is closed it is provider-dependent if this
method returns a reference to the closed file system or throws FileSystemNotFoundException. If the provider allows a new file system to
be created with the same URI as a file system it previously created then
this method throws the exception if invoked after the file system is
closed (and before a new instance is created by the newFileSystem method).
If a security manager is installed then a provider implementation
may require to check a permission before returning a reference to an
existing file system. In the case of the default file system, no permission check is required.
getFileSystem in class FileSystemProvideruri - URI referencepublic Path getPath(URI uri)
FileSystemProviderPath object by converting the given URI. The
resulting Path is associated with a FileSystem that
already exists or is constructed automatically.
The exact form of the URI is file system provider dependent. In the
case of the default provider, the URI scheme is "file" and the
given URI has a non-empty path component, and undefined query, and
fragment components. The resulting Path is associated with the
default default FileSystem.
If a security manager is installed then a provider implementation
may require to check a permission. In the case of the default file system, no permission check is
required.
getPath in class FileSystemProvideruri - The URI to convertPathpublic DirectoryStream<Path> newDirectoryStream(Path dir, DirectoryStream.Filter<? super Path> filter) throws IOException
FileSystemProviderDirectoryStream to iterate over
the entries in the directory. This method works in exactly the manner
specified by the Files.newDirectoryStream(java.nio.file.Path, java.nio.file.DirectoryStream.Filter)
method.newDirectoryStream in class FileSystemProviderdir - the path to the directoryfilter - the directory stream filterDirectoryStream objectNotDirectoryException - if the file could not otherwise be opened because it is not
a directory (optional specific exception)IOException - if an I/O error occurspublic void createDirectory(Path dir, FileAttribute<?>... attrs) throws IOException
FileSystemProviderFiles.createDirectory(java.nio.file.Path, java.nio.file.attribute.FileAttribute<?>...) method.createDirectory in class FileSystemProviderdir - the directory to createattrs - an optional list of file attributes to set atomically when
creating the directoryFileAlreadyExistsException - if a directory could not otherwise be created because a file of
that name already exists (optional specific exception)IOException - if an I/O error occurs or the parent directory does not existpublic void delete(Path path) throws IOException
FileSystemProviderFiles.delete(java.nio.file.Path) method.delete in class FileSystemProviderpath - the path to the file to deleteNoSuchFileException - if the file does not exist (optional specific exception)DirectoryNotEmptyException - if the file is a directory and could not otherwise be deleted
because the directory is not empty (optional specific
exception)IOException - if an I/O error occurspublic boolean deleteIfExists(Path path) throws IOException
FileSystemProviderFiles.deleteIfExists(java.nio.file.Path) method.
The default implementation of this method simply invokes FileSystemProvider.delete(java.nio.file.Path) ignoring the NoSuchFileException when the file does not
exist. It may be overridden where appropriate.
deleteIfExists in class FileSystemProviderpath - the path to the file to deletetrue if the file was deleted by this method; false if the file could not be deleted because it did not
existDirectoryNotEmptyException - if the file is a directory and could not otherwise be deleted
because the directory is not empty (optional specific
exception)IOException - if an I/O error occurspublic InputStream newInputStream(Path path, OpenOption... options) throws IOException
FileSystemProviderFiles.newInputStream(java.nio.file.Path, java.nio.file.OpenOption...) method.
The default implementation of this method opens a channel to the file
as if by invoking the FileSystemProvider.newByteChannel(java.nio.file.Path, java.util.Set<? extends java.nio.file.OpenOption>, java.nio.file.attribute.FileAttribute<?>...) method and constructs a
stream that reads bytes from the channel. This method should be overridden
where appropriate.
newInputStream in class FileSystemProviderpath - the path to the file to openoptions - options specifying how the file is openedIOException - if an I/O error occurspublic OutputStream newOutputStream(Path path, OpenOption... options) throws IOException
FileSystemProviderFiles.newOutputStream(java.nio.file.Path, java.nio.file.OpenOption...) method.
The default implementation of this method opens a channel to the file
as if by invoking the FileSystemProvider.newByteChannel(java.nio.file.Path, java.util.Set<? extends java.nio.file.OpenOption>, java.nio.file.attribute.FileAttribute<?>...) method and constructs a
stream that writes bytes to the channel. This method should be overridden
where appropriate.
newOutputStream in class FileSystemProviderpath - the path to the file to open or createoptions - options specifying how the file is openedIOException - if an I/O error occurspublic DesugarSeekableByteChannel newByteChannel(Path path, Set<? extends OpenOption> options, FileAttribute<?>... attrs) throws IOException
FileSystemProviderFiles.newByteChannel(Path,Set,FileAttribute[]) method.newByteChannel in class FileSystemProviderpath - the path to the file to open or createoptions - options specifying how the file is openedattrs - an optional list of file attributes to set atomically when
creating the fileFileAlreadyExistsException - if a file of that name already exists and the CREATE_NEW option is specified
(optional specific exception)IOException - if an I/O error occurspublic FileChannel newFileChannel(Path path, Set<? extends OpenOption> options, FileAttribute<?>... attrs) throws IOException
FileSystemProviderFileChannel.open method. A provider that does not support all the
features required to construct a file channel throws UnsupportedOperationException. The default provider is required to
support the creation of file channels. When not overridden, the default
implementation throws UnsupportedOperationException.newFileChannel in class FileSystemProviderpath - the path of the file to open or createoptions - options specifying how the file is openedattrs - an optional list of file attributes to set atomically when
creating the fileIOException - If an I/O error occurspublic AsynchronousFileChannel newAsynchronousFileChannel(Path path, Set<? extends OpenOption> options, ExecutorService executor, FileAttribute<?>... attrs) throws IOException
FileSystemProviderAsynchronousFileChannel.open method.
A provider that does not support all the features required to construct
an asynchronous file channel throws UnsupportedOperationException.
The default provider is required to support the creation of asynchronous
file channels. When not overridden, the default implementation of this
method throws UnsupportedOperationException.newAsynchronousFileChannel in class FileSystemProviderpath - the path of the file to open or createoptions - options specifying how the file is openedexecutor - the thread pool or null to associate the channel with
the default thread poolattrs - an optional list of file attributes to set atomically when
creating the fileIOException - If an I/O error occurspublic void createLink(Path link, Path existing) throws IOException
FileSystemProviderFiles.createLink(java.nio.file.Path, java.nio.file.Path)
method.
The default implementation of this method throws UnsupportedOperationException.
createLink in class FileSystemProviderlink - the link (directory entry) to createexisting - a path to an existing fileFileAlreadyExistsException - if the entry could not otherwise be created because a file of
that name already exists (optional specific exception)IOException - if an I/O error occurspublic void createSymbolicLink(Path link, Path target, FileAttribute<?>... attrs) throws IOException
FileSystemProviderFiles.createSymbolicLink(java.nio.file.Path, java.nio.file.Path, java.nio.file.attribute.FileAttribute<?>...) method.
The default implementation of this method throws UnsupportedOperationException.
createSymbolicLink in class FileSystemProviderlink - the path of the symbolic link to createtarget - the target of the symbolic linkattrs - the array of attributes to set atomically when creating the
symbolic linkFileAlreadyExistsException - if a file with the name already exists (optional specific
exception)IOException - if an I/O error occurspublic Path readSymbolicLink(Path link) throws IOException
FileSystemProviderFiles.readSymbolicLink(java.nio.file.Path) method.
The default implementation of this method throws UnsupportedOperationException.
readSymbolicLink in class FileSystemProviderlink - the path to the symbolic linkNotLinkException - if the target could otherwise not be read because the file
is not a symbolic link (optional specific exception)IOException - if an I/O error occurspublic void copy(Path source, Path target, CopyOption... options) throws IOException
FileSystemProviderFiles.copy(Path,Path,CopyOption[]) method
except that both the source and target paths must be associated with
this provider.copy in class FileSystemProvidersource - the path to the file to copytarget - the path to the target fileoptions - options specifying how the copy should be doneFileAlreadyExistsException - 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)IOException - if an I/O error occurspublic void move(Path source, Path target, CopyOption... options) throws IOException
FileSystemProviderFiles.move(java.nio.file.Path, java.nio.file.Path, java.nio.file.CopyOption...) method except that both the
source and target paths must be associated with this provider.move in class FileSystemProvidersource - the path to the file to movetarget - the path to the target fileoptions - options specifying how the move should be doneFileAlreadyExistsException - 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)AtomicMoveNotSupportedException - if the options array contains the ATOMIC_MOVE option but
the file cannot be moved as an atomic file system operation.IOException - if an I/O error occurspublic boolean isSameFile(Path path, Path path2) throws IOException
FileSystemProviderFiles.isSameFile(java.nio.file.Path, java.nio.file.Path) method.isSameFile in class FileSystemProviderpath - one path to the filepath2 - the other pathtrue if, and only if, the two paths locate the same fileIOException - if an I/O error occurspublic boolean isHidden(Path path) throws IOException
FileSystemProviderFiles.isHidden(java.nio.file.Path)
method.
This method is invoked by the isHidden method.
isHidden in class FileSystemProviderpath - the path to the file to testtrue if the file is considered hiddenIOException - if an I/O error occurspublic FileStore getFileStore(Path path) throws IOException
FileSystemProviderFileStore representing the file store where a file
is located. This method works in exactly the manner specified by the
Files.getFileStore(java.nio.file.Path) method.getFileStore in class FileSystemProviderpath - the path to the fileIOException - if an I/O error occurspublic <V extends FileAttributeView> V getFileAttributeView(Path path, Class<V> type, LinkOption... options)
FileSystemProviderFiles.getFileAttributeView(java.nio.file.Path, java.lang.Class<V>, java.nio.file.LinkOption...)
method.getFileAttributeView in class FileSystemProviderV - The FileAttributeView typepath - the path to the filetype - the Class object corresponding to the file attribute viewoptions - options indicating how symbolic links are handlednull if
the attribute view type is not availablepublic void checkAccess(Path path, AccessMode... modes) throws IOException
FileSystemProvider This method may be used by the isReadable,
isWritable and isExecutable methods to check the accessibility of a file.
This method checks the existence of a file and that this Java virtual
machine has appropriate privileges that would allow it access the file
according to all of access modes specified in the modes parameter
as follows:
| Value | Description |
|---|---|
READ |
Checks that the file exists and that the Java virtual machine has permission to read the file. |
WRITE |
Checks that the file exists and that the Java virtual machine has permission to write to the file, |
EXECUTE |
Checks that the file exists and that the Java virtual machine has
permission to execute the file. The semantics
may differ when checking access to a directory. For example, on UNIX
systems, checking for EXECUTE access checks that the Java
virtual machine has permission to search the directory in order to
access file or subdirectories. |
If the modes parameter is of length zero, then the existence
of the file is checked.
This method follows symbolic links if the file referenced by this object is a symbolic link. Depending on the implementation, this method may require to read file permissions, access control lists, or other file attributes in order to check the effective access to the file. To determine the effective access to a file may require access to several attributes and so in some implementations this method may not be atomic with respect to other file system operations.
checkAccess in class FileSystemProviderpath - the path to the file to checkmodes - The access modes to check; may have zero elementsNoSuchFileException - if a file does not exist (optional specific exception)AccessDeniedException - the requested access would be denied or the access cannot be
determined because the Java virtual machine has insufficient
privileges or other reasons. (optional specific exception)IOException - if an I/O error occurspublic <A extends BasicFileAttributes> A readAttributes(Path path, Class<A> type, LinkOption... options) throws IOException
FileSystemProviderFiles.readAttributes(Path,Class,LinkOption[]) method.readAttributes in class FileSystemProviderA - The BasicFileAttributes typepath - the path to the filetype - the Class of the file attributes required
to readoptions - options indicating how symbolic links are handledIOException - if an I/O error occurspublic Map<String,Object> readAttributes(Path path, String attributes, LinkOption... options) throws IOException
FileSystemProviderFiles.readAttributes(Path,String,LinkOption[]) method.readAttributes in class FileSystemProviderpath - the path to the fileattributes - the attributes to readoptions - options indicating how symbolic links are handledIOException - If an I/O error occurspublic void setAttribute(Path path, String attribute, Object value, LinkOption... options) throws IOException
FileSystemProviderFiles.setAttribute(java.nio.file.Path, java.lang.String, java.lang.Object, java.nio.file.LinkOption...) method.setAttribute in class FileSystemProviderpath - the path to the fileattribute - the attribute to setvalue - the attribute valueoptions - options indicating how symbolic links are handledIOException - If an I/O error occurs