< prev index next >

src/java.base/share/classes/java/nio/file/FileSystems.java

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 2007, 2018, 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 * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * 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 * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 363,377 **** * * <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. * ! * <p> 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 * 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 --- 363,375 ---- * * <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. * ! * <p> 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. * * @param path
*** 394,407 **** */ public static FileSystem newFileSystem(Path path, ClassLoader loader) throws IOException { if (path == null) throw new NullPointerException(); - Map<String,?> env = Collections.emptyMap(); - // check installed providers for (FileSystemProvider provider: FileSystemProvider.installedProviders()) { try { return provider.newFileSystem(path, env); } catch (UnsupportedOperationException uoe) { --- 392,528 ---- */ public static FileSystem newFileSystem(Path path, 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. + * + * <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. + * + * <p> 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<String,?> env) + throws IOException + { + return newFileSystem(path, env, null); + } + + /** + * 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. + * + * <p> 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 with an empty map to construct the new file system. + * + * @param path + * the path to the file + * + * @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) + throws IOException + { + return newFileSystem(path, Map.of(), null); + } + + /** + * 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. + * + * <p> 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<String,?> env, + ClassLoader loader) + throws IOException + { if (path == null) throw new NullPointerException(); // check installed providers for (FileSystemProvider provider: FileSystemProvider.installedProviders()) { try { return provider.newFileSystem(path, env); } catch (UnsupportedOperationException uoe) {
< prev index next >