src/share/classes/java/nio/file/FileSystems.java
Print this page
@@ -162,12 +162,12 @@
* by invoking it with a reference to the system-default provider.
* The second provider class is instantiated by invoking it with a reference
* to the first provider instance. The third provider class is instantiated
* by invoking it with a reference to the second instance, and so on. The
* last provider to be instantiated becomes the default provider; its {@code
- * getFileSystem} method is invoked with the URI {@code "file:///"} to create
- * the default file system.
+ * getFileSystem} method is invoked with the URI {@code "file:///"} to
+ * get a reference to the default file system.
*
* <p> Subsequent invocations of this method return the file system that was
* returned by the first invocation.
*
* @return the default file system
@@ -236,11 +236,11 @@
*
* <p> <b>Usage Example:</b>
* Suppose there is a provider identified by the scheme {@code "memory"}
* installed:
* <pre>
- * Map<String,String> env = new HashMap<String,String>();
+ * Map<String,String> env = new HashMap<>();
* env.put("capacity", "16G");
* env.put("blockSize", "4k");
* FileSystem fs = FileSystems.newFileSystem(URI.create("memory:///?name=logfs"), env);
* </pre>
*
@@ -341,37 +341,29 @@
* Constructs a new {@code FileSystem} to access the contents of a file as a
* file system.
*
* <p> 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. The {@code file} parameter is a reference to an existing file
- * and the {@code env} parameter is a map of provider specific properties to
- * configure the file system.
+ * system.
*
* <p> This method iterates over the {@link FileSystemProvider#installedProviders()
* installed} providers. It invokes, in turn, each provider's {@link
- * FileSystemProvider#newFileSystem(FileRef,Map) newFileSystem(FileRef,Map)} method.
- * If a provider returns a file system then the iteration terminates
- * and the file system is returned. If none of the installed providers return
- * a {@code FileSystem} then an attempt is made to locate the provider using
- * the given class loader. If a provider returns a file system then the lookup
- * terminates and the file system is returned.
+ * FileSystemProvider#newFileSystem(Path,Map) newFileSystem(Path,Map)} method
+ * with an empty map. If a provider returns a file system then the iteration
+ * terminates and the file system is returned. If none of the installed
+ * providers return a {@code FileSystem} then an attempt is made to locate
+ * the provider using the given class loader. If a provider returns a file
+ * system then the lookup terminates and the file system is returned.
*
- * @param file
- * a reference to a file
- * @param env
- * a map of provider specific properties to configure the file system;
- * may be empty
+ * @param path
+ * the path to the file
* @param loader
* the class loader to locate the provider or {@code null} to only
* attempt to locate an installed provider
*
* @return a new file system
*
- * @throws IllegalArgumentException
- * if the {@code env} parameter does not contain properties required
- * by the provider, or a property value is invalid
* @throws ProviderNotFoundException
* if a provider supporting this file type cannot be located
* @throws ServiceConfigurationError
* when an error occurs while loading a service provider
* @throws IOException
@@ -378,22 +370,22 @@
* if an I/O error occurs
* @throws SecurityException
* if a security manager is installed and it denies an unspecified
* permission
*/
- public static FileSystem newFileSystem(FileRef file,
- Map<String,?> env,
+ public static FileSystem newFileSystem(Path path,
ClassLoader loader)
throws IOException
{
- if (file == null)
+ if (path == null)
throw new NullPointerException();
+ Map<String,?> env = Collections.emptyMap();
// check installed providers
for (FileSystemProvider provider: FileSystemProvider.installedProviders()) {
try {
- return provider.newFileSystem(file, env);
+ return provider.newFileSystem(path, env);
} catch (UnsupportedOperationException uoe) {
}
}
// if not found, use service-provider loading facility
@@ -400,11 +392,11 @@
if (loader != null) {
ServiceLoader<FileSystemProvider> sl = ServiceLoader
.load(FileSystemProvider.class, loader);
for (FileSystemProvider provider: sl) {
try {
- return provider.newFileSystem(file, env);
+ return provider.newFileSystem(path, env);
} catch (UnsupportedOperationException uoe) {
}
}
}