FileSystem (Java SE 15 & JDK 15) (original) (raw)

All Implemented Interfaces:

[Closeable](../../io/Closeable.html "interface in java.io"), [AutoCloseable](../../lang/AutoCloseable.html "interface in java.lang")


public abstract class FileSystem extends Object implements Closeable

Provides an interface to a file system and is the factory for objects to access files and other objects in the file system.

The default file system, obtained by invoking the FileSystems.getDefault method, provides access to the file system that is accessible to the Java virtual machine. The FileSystems class defines methods to create file systems that provide access to other types of (custom) file systems.

A file system is the factory for several types of objects:

File systems vary greatly. In some cases the file system is a single hierarchy of files with one top-level root directory. In other cases it may have several distinct file hierarchies, each with its own top-level root directory. The getRootDirectories method may be used to iterate over the root directories in the file system. A file system is typically composed of one or more underlying file-stores that provide the storage for the files. Theses file stores can also vary in the features they support, and the file attributes or meta-data that they associate with files.

A file system is open upon creation and can be closed by invoking itsclose method. Once closed, any further attempt to access objects in the file system cause ClosedFileSystemException to be thrown. File systems created by the default provider cannot be closed.

A FileSystem can provide read-only or read-write access to the file system. Whether or not a file system provides read-only access is established when the FileSystem is created and can be tested by invoking its isReadOnly method. Attempts to write to file stores by means of an object associated with a read-only file system throws ReadOnlyFileSystemException.

File systems are safe for use by multiple concurrent threads. The close method may be invoked at any time to close a file system but whether a file system is asynchronously closeable is provider specific and therefore unspecified. In other words, if a thread is accessing an object in a file system, and another thread invokes the close method then it may require to block until the first operation is complete. Closing a file system causes all open channels, watch services, and other closeable objects associated with the file system to be closed.

Since:

1.7

Constructors

Modifier Constructor Description
protected FileSystem() Initializes a new instance of this class.
Modifier and Type Method Description
abstract void close() Closes this file system.
abstract Iterable<FileStore> getFileStores() Returns an object to iterate over the underlying file stores.
abstract Path getPath​(String first,String... more) Converts a path string, or a sequence of strings that when joined form a path string, to a Path.
abstract PathMatcher getPathMatcher​(String syntaxAndPattern) Returns a PathMatcher that performs match operations on theString representation of Path objects by interpreting a given pattern.
abstract Iterable<Path> getRootDirectories() Returns an object to iterate over the paths of the root directories.
abstract String getSeparator() Returns the name separator, represented as a string.
abstract UserPrincipalLookupService getUserPrincipalLookupService() Returns the UserPrincipalLookupService for this file system_(optional operation)_.
abstract boolean isOpen() Tells whether or not this file system is open.
abstract boolean isReadOnly() Tells whether or not this file system allows only read-only access to its file stores.
abstract WatchService newWatchService() Constructs a new WatchService (optional operation).
abstract FileSystemProvider provider() Returns the provider that created this file system.
abstract Set<String> supportedFileAttributeViews() Returns the set of the names of the file attribute views supported by this FileSystem.

Methods declared in class java.lang.Object

[clone](../../lang/Object.html#clone%28%29), [equals](../../lang/Object.html#equals%28java.lang.Object%29), [finalize](../../lang/Object.html#finalize%28%29), [getClass](../../lang/Object.html#getClass%28%29), [hashCode](../../lang/Object.html#hashCode%28%29), [notify](../../lang/Object.html#notify%28%29), [notifyAll](../../lang/Object.html#notifyAll%28%29), [toString](../../lang/Object.html#toString%28%29), [wait](../../lang/Object.html#wait%28%29), [wait](../../lang/Object.html#wait%28long%29), [wait](../../lang/Object.html#wait%28long,int%29)