GeezerVison is showing docs.oracle.com — FileSystemProvider (Java Platform SE 8 )
Java™ Platform Standard Ed. 8
compact1, compact2, compact3
java.nio.file.spi
Class FileSystemProvider
-
-
Constructor Summary
Constructors
| Modifier |
Constructor |
Description |
protected |
FileSystemProvider() |
Initializes a new instance of this class.
|
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods
| Modifier and Type |
Method |
Description |
abstract void |
checkAccess(Path path,
AccessMode... modes) |
Checks the existence, and optionally the accessibility, of a file.
|
abstract void |
copy(Path source,
Path target,
CopyOption... options) |
Copy a file to a target file.
|
abstract 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.
|
abstract void |
delete(Path path) |
Deletes a file.
|
boolean |
deleteIfExists(Path path) |
Deletes a file if it exists.
|
abstract <V extends FileAttributeView> V |
getFileAttributeView(Path path,
Class<V> type,
LinkOption... options) |
Returns a file attribute view of a given type.
|
abstract FileStore |
getFileStore(Path path) |
Returns the FileStore representing the file store where a file
is located.
|
abstract FileSystem |
getFileSystem(URI uri) |
Returns an existing FileSystem created by this provider.
|
abstract Path |
getPath(URI uri) |
Return a Path object by converting the given URI.
|
abstract String |
getScheme() |
Returns the URI scheme that identifies this provider.
|
static List<FileSystemProvider> |
installedProviders() |
Returns a list of the installed file system providers.
|
abstract boolean |
isHidden(Path path) |
Tells whether or not a file is considered hidden.
|
abstract boolean |
isSameFile(Path path,
Path path2) |
Tests if two paths locate the same file.
|
abstract 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.
|
abstract SeekableByteChannel |
newByteChannel(Path path,
Set<? extends OpenOption> options,
FileAttribute<?>... attrs) |
Opens or creates a file, returning a seekable byte channel to access the
file.
|
abstract 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.
|
FileSystem |
newFileSystem(Path path,
Map<String,?> env) |
Constructs a new FileSystem to access the contents of a file as a
file system.
|
abstract FileSystem |
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.
|
abstract <A extends BasicFileAttributes> A |
readAttributes(Path path,
Class<A> type,
LinkOption... options) |
Reads a file's attributes as a bulk operation.
|
abstract 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.
|
abstract void |
setAttribute(Path path,
String attribute,
Object value,
LinkOption... options) |
Sets the value of a file attribute.
|
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
newAsynchronousFileChannel
public AsynchronousFileChannel newAsynchronousFileChannel(Path path,
Set<? extends OpenOption> options,
ExecutorService executor,
FileAttribute<?>... attrs)
throws IOException
Opens or creates a file for reading and/or writing, returning an
asynchronous file channel to access the file. This method works in
exactly the manner specified by the AsynchronousFileChannel.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.
- Parameters:
path - the path of the file to open or create
options - options specifying how the file is opened
executor - the thread pool or null to associate the channel with
the default thread pool
attrs - an optional list of file attributes to set atomically when
creating the file
- Returns:
- a new asynchronous file channel
- Throws:
IllegalArgumentException - If the set contains an invalid combination of options
UnsupportedOperationException - If this provider that does not support creating asynchronous file
channels, or an unsupported open option or file attribute is
specified
IOException - If an I/O error occurs
SecurityException - In the case of the default file system, the SecurityManager.checkRead(String) method is invoked to check
read access if the file is opened for reading. The SecurityManager.checkWrite(String) method is invoked to check
write access if the file is opened for writing
-
readAttributes
public abstract Map<String,Object> readAttributes(Path path,
String attributes,
LinkOption... options)
throws IOException
- Parameters:
path - the path to the file
attributes - the attributes to read
options - options indicating how symbolic links are handled
- Returns:
- a map of the attributes returned; may be empty. The map's keys
are the attribute names, its values are the attribute values
- Throws:
UnsupportedOperationException - if the attribute view is not available
IllegalArgumentException - if no attributes are specified or an unrecognized attributes is
specified
IOException - If an I/O error occurs
SecurityException - In the case of the default provider, and a security manager is
installed, its checkRead
method denies read access to the file. If this method is invoked
to read security sensitive attributes then the security manager
may be invoke to check for additional permissions.
-
setAttribute
public abstract void setAttribute(Path path,
String attribute,
Object value,
LinkOption... options)
throws IOException
- Parameters:
path - the path to the file
attribute - the attribute to set
value - the attribute value
options - options indicating how symbolic links are handled
- Throws:
UnsupportedOperationException - if the attribute view is not available
IllegalArgumentException - if the attribute name is not specified, or is not recognized, or
the attribute value is of the correct type but has an
inappropriate value
ClassCastException - If the attribute value is not of the expected type or is a
collection containing elements that are not of the expected
type
IOException - If an I/O error occurs
SecurityException - In the case of the default provider, and a security manager is
installed, its checkWrite
method denies write access to the file. If this method is invoked
to set security sensitive attributes then the security manager
may be invoked to check for additional permissions.
Java™ Platform Standard Ed. 8
Submit a bug or feature For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples. Copyright © 1993, 2026, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.
|