The default file system, obtained by invoking the {@link FileSystems#getDefault FileSystems.getDefault} method, provides access to the file system that isaccessible to the Java virtual machine. The {@link FileSystems} class definesmethods 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:
The {@link #getPath getPath} method converts a system dependentpath string, returning a {@link Path} object that may be usedto locate and access a file.
The {@link #getPathMatcher getPathMatcher} method is usedto create a {@link PathMatcher} that performs match operations onpaths.
The {@link #getFileStores getFileStores} method returns an iteratorover the underlying {@link FileStore file-stores}.
The {@link #getUserPrincipalLookupService getUserPrincipalLookupService}method returns the {@link UserPrincipalLookupService} to lookup users orgroups by name.
The {@link #newWatchService newWatchService} method creates a{@link WatchService} that may be used to watch objects for changes andevents.
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 {@link #getRootDirectories getRootDirectories} method may beused to iterate over the root directories in the file system. A file system is typically composed of one or more underlying {@link FileStore 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 its {@link #close() close} method. Once closed, any further attempt to accessobjects in the file system cause {@link ClosedFileSystemException} to bethrown. File systems created by the default {@link FileSystemProvider provider}cannot be closed.
A {@code FileSystem} can provide read-only or read-write access to thefile system. Whether or not a file system provides read-only access is established when the {@code FileSystem} is created and can be tested by invokingits {@link #isReadOnly() isReadOnly} method. Attempts to write to file storesby means of an object associated with a read-only file system throws {@link ReadOnlyFileSystemException}.
File systems are safe for use by multiple concurrent threads. The {@link #close close} method may be invoked at any time to close a file system butwhether 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 {@code close} methodthen it may require to block until the first operation is complete. Closing a file system causes all open channels, watch services, and other {@link Closeable closeable} objects associated with the file system to be closed. @since 1.7
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|