getDefault
method to get the default file system and factory methods to
construct other types of file systems.
The first invocation of any of the methods defined by this class causes
the default provider
to be loaded. The default
provider, identified by the URI scheme "file", creates the FileSystem
that provides access to the file systems accessible to the Java virtual
machine. If the process of loading or initializing the default provider fails
then an unspecified error is thrown.
The first invocation of the installedProviders
method, by way of invoking any of the newFileSystem
methods defined by this class, locates and loads all
installed file system providers. Installed providers are loaded using the
service-provider loading facility defined by the ServiceLoader
class.
Installed providers are loaded using the system class loader. If the
system class loader cannot be found then the platform class loader is used.
Providers are typically installed by placing them in a JAR file on the
application class path, the JAR file contains a
provider-configuration file named java.nio.file.spi.FileSystemProvider
in the resource directory META-INF/services
, and the file lists one or
more fully-qualified names of concrete subclass of FileSystemProvider
that have a zero argument constructor.
The ordering that installed providers are located is implementation specific.
If a provider is instantiated and its getScheme
returns the same URI scheme of a provider that was previously
instantiated then the most recently instantiated duplicate is discarded. URI
schemes are compared without regard to case. During construction a provider
may safely access files associated with the default provider but care needs
to be taken to avoid circular loading of other installed providers. If
circular loading of installed providers is detected then an unspecified error
is thrown.
This class also defines factory methods that allow a ClassLoader
to be specified when locating a provider. As with installed providers, the
provider classes are identified by placing the provider configuration file
in the resource directory META-INF/services
.
If a thread initiates the loading of the installed file system providers and another thread invokes a method that also attempts to load the providers then the method will block until the loading completes.
Modifier and Type | Class and Description |
---|---|
private static class |
Access | Constructor and Description |
---|---|
private |
Modifier and Type | Method and Description |
---|---|
public static FileSystem | |
public static FileSystem | Returns: the reference to the file systemthe URI to locate the file system uri)Returns a reference to an existing |
public static FileSystem | Returns: a new file systemthe URI identifying the file system uri, Map<String, ?> a map of provider specific properties to configure the file system;
may be empty env)Constructs a new file system that is identified by a This method iterates over the |
public static FileSystem | Returns: a new file systemthe URI identifying the file system uri, Map<String, ?> a map of provider specific properties to configure the file system;
may be empty env, ClassLoader the class loader to locate the provider or loader)null to only
attempt to locate an installed providerConstructs a new file system that is identified by a This method first attempts to locate an installed provider in exactly
the same manner as the |
public static FileSystem | Returns: a new file systemthe path to the file path, ClassLoader the class loader to locate the provider or loader)null to only
attempt to locate an installed providerConstructs a new |
public static FileSystem | Returns: a new file systemthe path to the file path, Map<String, ?> a map of provider specific properties to configure the file system;
may be empty env)Constructs a new |
public static FileSystem | Returns: a new file systemthe path to the file path)Constructs a new |
public static FileSystem | Returns: a new file systemthe path to the file path, Map<String, ?> a map of provider specific properties to configure the file system;
may be empty env, ClassLoader the class loader to locate the provider or loader)null to only
attempt to locate an installed providerConstructs a new |
FileSystems | back to summary |
---|---|
private FileSystems() |
getDefault | back to summary |
---|---|
public static FileSystem getDefault() Returns the default The first invocation of any of the methods defined by this class
locates the default If the system property Subsequent invocations of this method return the file system that was returned by the first invocation.
|
getFileSystem | back to summary |
---|---|
public static FileSystem getFileSystem(URI uri) Returns a reference to an existing This method iterates over the Once a file system created by this provider is 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
|
newFileSystem | back to summary |
---|---|
public static FileSystem newFileSystem(URI uri, Map<String, ?> env) throws IOException Constructs a new file system that is identified by a This method iterates over the Once a file system is Usage Example:
Suppose there is a provider identified by the scheme FileSystem fs = FileSystems.newFileSystem(URI.create("memory:///?name=logfs"), Map.of("capacity", "16G", "blockSize", "4k"));
|
newFileSystem | back to summary |
---|---|
public static FileSystem newFileSystem(URI uri, Map<String, ?> env, ClassLoader loader) throws IOException Constructs a new file system that is identified by a This method first attempts to locate an installed provider in exactly
the same manner as the
|
newFileSystem | back to summary |
---|---|
public static FileSystem newFileSystem(Path path, ClassLoader loader) throws IOException Constructs a new This method makes use of specialized providers that create pseudo file systems where the contents of one or more files is treated as a file system. This method first attempts to locate an installed provider in exactly
the same manner as the
|
newFileSystem | back to summary |
---|---|
public static FileSystem newFileSystem(Path path, Map<String, ?> env) throws IOException Constructs a new This method makes use of specialized providers that create pseudo file systems where the contents of one or more files is treated as a file system. This method first attempts to locate an installed provider in exactly
the same manner as the
|
newFileSystem | back to summary |
---|---|
public static FileSystem newFileSystem(Path path) throws IOException Constructs a new This method makes use of specialized providers that create pseudo file systems where the contents of one or more files is treated as a file system. This method first attempts to locate an installed provider in exactly
the same manner as the
|
newFileSystem | back to summary |
---|---|
public static FileSystem newFileSystem(Path path, Map<String, ?> env, ClassLoader loader) throws IOException Constructs a new This method makes use of specialized providers that create pseudo file systems where the contents of one or more files is treated as a file system. This method iterates over the
|
Modifier and Type | Field and Description |
---|---|
pack-priv static final FileSystem |
Access | Constructor and Description |
---|---|
private |
Modifier and Type | Method and Description |
---|---|
private static FileSystem | |
private static FileSystemProvider |
defaultFileSystem | back to summary |
---|---|
pack-priv static final FileSystem defaultFileSystem |
DefaultFileSystemHolder | back to summary |
---|---|
private DefaultFileSystemHolder() |
defaultFileSystem | back to summary |
---|---|
private static FileSystem defaultFileSystem() |
getDefaultProvider | back to summary |
---|---|
private static FileSystemProvider getDefaultProvider() |