--- old/src/java.base/share/classes/java/nio/file/FileSystems.java 2019-02-19 15:44:16.000000000 -0500 +++ new/src/java.base/share/classes/java/nio/file/FileSystems.java 2019-02-19 15:44:16.000000000 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -365,11 +365,9 @@ * systems where the contents of one or more files is treated as a file * system. * - *

This method iterates over the {@link FileSystemProvider#installedProviders() - * installed} providers. It invokes, in turn, each provider's {@link - * 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 + *

This method first attempts to locate an installed provider in exactly + * the same manner as the {@link #newFileSystem(Path, Map, ClassLoader) + * newFileSystem(Path, Map, ClassLoader)} with an empty map. 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. @@ -396,9 +394,96 @@ ClassLoader loader) throws IOException { + return newFileSystem(path, Map.of(), loader); + } + + /** + * Constructs a new {@code FileSystem} to access the contents of a file as a + * file system. + * + *

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 {@link #newFileSystem(Path,Map,ClassLoader) + * newFileSystem(Path, Map, ClassLoader)}. If found, the provider's + * {@link FileSystemProvider#newFileSystem(Path, Map) newFileSystem(Path, Map)} + * method is invoked to construct the new file system. + * + * @param path + * the path to the file + * @param env + * a map of provider specific properties to configure the file system; + * may be empty + * + * @return a new file system + * + * @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 + * if an I/O error occurs + * @throws SecurityException + * if a security manager is installed and it denies an unspecified + * permission + * + * @since 13 + */ + public static FileSystem newFileSystem(Path path, Map env) + throws IOException + { + return newFileSystem(path, env, null); + } + + /** + * Constructs a new {@code FileSystem} to access the contents of a file as a + * file system. + * + *

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 {@link FileSystemProvider#installedProviders() + * installed} providers. It invokes, in turn, each provider's {@link + * FileSystemProvider#newFileSystem(Path,Map) newFileSystem(Path,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. + * + * @param path + * the path to the file + * @param env + * a map of provider specific properties to configure the file system; + * may be empty + * @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 ProviderNotFoundException + * if a provider supporting this file type cannot be located + * @throws ServiceConfigurationError + * when an error occurs while loading a service provider + * @throws IOException + * if an I/O error occurs + * @throws SecurityException + * if a security manager is installed and it denies an unspecified + * permission + * + * @since 13 + */ + public static FileSystem newFileSystem(Path path, Map env, + ClassLoader loader) + throws IOException + { if (path == null) throw new NullPointerException(); - Map env = Collections.emptyMap(); // check installed providers for (FileSystemProvider provider: FileSystemProvider.installedProviders()) {