Java Code Examples for java.nio.file.spi.FileSystemProvider#installedProviders()
The following examples show how to use
java.nio.file.spi.FileSystemProvider#installedProviders() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CompileTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
boolean isJarFileSystemAvailable() { boolean result = false; for (FileSystemProvider fsp: FileSystemProvider.installedProviders()) { String scheme = fsp.getScheme(); System.err.println("Provider: " + scheme + " " + fsp); if (scheme.equalsIgnoreCase("jar") || scheme.equalsIgnoreCase("zip")) result = true; } return result; }
Example 2
Source File: GitFileSystemProvider.java From ParallelGit with Apache License 2.0 | 5 votes |
@Nonnull private static GitFileSystemProvider getInstalledProvider() { GitFileSystemProvider ret = null; for(FileSystemProvider provider : FileSystemProvider.installedProviders()) { if(provider instanceof GitFileSystemProvider) { ret = (GitFileSystemProvider) provider; break; } } if(ret == null) ret = new GitFileSystemProvider(); return ret; }
Example 3
Source File: FSInfo.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public synchronized FileSystemProvider getJarFSProvider() { if (jarFSProvider != null) { return jarFSProvider; } for (FileSystemProvider provider: FileSystemProvider.installedProviders()) { if (provider.getScheme().equals("jar")) { return (jarFSProvider = provider); } } return null; }
Example 4
Source File: CompileTest.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
boolean isJarFileSystemAvailable() { boolean result = false; for (FileSystemProvider fsp: FileSystemProvider.installedProviders()) { String scheme = fsp.getScheme(); System.err.println("Provider: " + scheme + " " + fsp); if (scheme.equalsIgnoreCase("jar") || scheme.equalsIgnoreCase("zip")) result = true; } return result; }
Example 5
Source File: BundleFileSystemProvider.java From incubator-taverna-language with Apache License 2.0 | 5 votes |
public static BundleFileSystemProvider getInstance() { for (FileSystemProvider provider : FileSystemProvider .installedProviders()) { if (provider instanceof BundleFileSystemProvider) { return (BundleFileSystemProvider) provider; } } // Not installed! // Fallback for OSGi environments return Singleton.INSTANCE; }
Example 6
Source File: CompileTest.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
boolean isJarFileSystemAvailable() { boolean result = false; for (FileSystemProvider fsp: FileSystemProvider.installedProviders()) { String scheme = fsp.getScheme(); System.err.println("Provider: " + scheme + " " + fsp); if (scheme.equalsIgnoreCase("jar") || scheme.equalsIgnoreCase("zip")) result = true; } return result; }
Example 7
Source File: Basic.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { Path zipfile = Paths.get(args[0]); // Test: zip should should be returned in provider list boolean found = false; for (FileSystemProvider provider: FileSystemProvider.installedProviders()) { if (provider.getScheme().equalsIgnoreCase("jar")) { found = true; break; } } if (!found) throw new RuntimeException("'jar' provider not installed"); // Test: FileSystems#newFileSystem(Path) Map<String,?> env = new HashMap<String,Object>(); FileSystems.newFileSystem(zipfile, null).close(); // Test: FileSystems#newFileSystem(URI) URI uri = new URI("jar", zipfile.toUri().toString(), null); FileSystem fs = FileSystems.newFileSystem(uri, env, null); // Test: exercise toUri method String expected = uri.toString() + "!/foo"; String actual = fs.getPath("/foo").toUri().toString(); if (!actual.equals(expected)) { throw new RuntimeException("toUri returned '" + actual + "', expected '" + expected + "'"); } // Test: exercise directory iterator and retrieval of basic attributes Files.walkFileTree(fs.getPath("/"), new FileTreePrinter()); // Test: DirectoryStream found = false; try (DirectoryStream<Path> stream = Files.newDirectoryStream(fs.getPath("/"))) { for (Path entry: stream) { found = entry.toString().equals("/META-INF/"); if (found) break; } } if (!found) throw new RuntimeException("Expected file not found"); // Test: copy file from zip file to current (scratch) directory Path source = fs.getPath("/META-INF/services/java.nio.file.spi.FileSystemProvider"); if (Files.exists(source)) { Path target = Paths.get(source.getFileName().toString()); Files.copy(source, target, StandardCopyOption.REPLACE_EXISTING); try { long s1 = Files.readAttributes(source, BasicFileAttributes.class).size(); long s2 = Files.readAttributes(target, BasicFileAttributes.class).size(); if (s2 != s1) throw new RuntimeException("target size != source size"); } finally { Files.delete(target); } } // Test: FileStore FileStore store = Files.getFileStore(fs.getPath("/")); if (!store.supportsFileAttributeView("basic")) throw new RuntimeException("BasicFileAttributeView should be supported"); // Test: ClosedFileSystemException fs.close(); if (fs.isOpen()) throw new RuntimeException("FileSystem should be closed"); try { fs.provider().checkAccess(fs.getPath("/missing"), AccessMode.READ); } catch (ClosedFileSystemException x) { } }
Example 8
Source File: Basic.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { Path zipfile = Paths.get(args[0]); // Test: zip should should be returned in provider list boolean found = false; for (FileSystemProvider provider: FileSystemProvider.installedProviders()) { if (provider.getScheme().equalsIgnoreCase("jar")) { found = true; break; } } if (!found) throw new RuntimeException("'jar' provider not installed"); // Test: FileSystems#newFileSystem(Path) Map<String,?> env = new HashMap<String,Object>(); FileSystems.newFileSystem(zipfile, null).close(); // Test: FileSystems#newFileSystem(URI) URI uri = new URI("jar", zipfile.toUri().toString(), null); FileSystem fs = FileSystems.newFileSystem(uri, env, null); // Test: exercise toUri method String expected = uri.toString() + "!/foo"; String actual = fs.getPath("/foo").toUri().toString(); if (!actual.equals(expected)) { throw new RuntimeException("toUri returned '" + actual + "', expected '" + expected + "'"); } // Test: exercise directory iterator and retrieval of basic attributes Files.walkFileTree(fs.getPath("/"), new FileTreePrinter()); // Test: DirectoryStream found = false; try (DirectoryStream<Path> stream = Files.newDirectoryStream(fs.getPath("/"))) { for (Path entry: stream) { found = entry.toString().equals("/META-INF/"); if (found) break; } } if (!found) throw new RuntimeException("Expected file not found"); // Test: copy file from zip file to current (scratch) directory Path source = fs.getPath("/META-INF/services/java.nio.file.spi.FileSystemProvider"); if (Files.exists(source)) { Path target = Paths.get(source.getFileName().toString()); Files.copy(source, target, StandardCopyOption.REPLACE_EXISTING); try { long s1 = Files.readAttributes(source, BasicFileAttributes.class).size(); long s2 = Files.readAttributes(target, BasicFileAttributes.class).size(); if (s2 != s1) throw new RuntimeException("target size != source size"); } finally { Files.delete(target); } } // Test: FileStore FileStore store = Files.getFileStore(fs.getPath("/")); if (!store.supportsFileAttributeView("basic")) throw new RuntimeException("BasicFileAttributeView should be supported"); // Test: ClosedFileSystemException fs.close(); if (fs.isOpen()) throw new RuntimeException("FileSystem should be closed"); try { fs.provider().checkAccess(fs.getPath("/missing"), AccessMode.READ); } catch (ClosedFileSystemException x) { } }
Example 9
Source File: Stat.java From google-cloud-java with Apache License 2.0 | 4 votes |
private static void listFilesystems() { System.out.println("Installed filesystem providers:"); for (FileSystemProvider p : FileSystemProvider.installedProviders()) { System.out.println(" " + p.getScheme()); } }
Example 10
Source File: Basic.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { Path zipfile = Paths.get(args[0]); // Test: zip should should be returned in provider list boolean found = false; for (FileSystemProvider provider: FileSystemProvider.installedProviders()) { if (provider.getScheme().equalsIgnoreCase("jar")) { found = true; break; } } if (!found) throw new RuntimeException("'jar' provider not installed"); // Test: FileSystems#newFileSystem(Path) Map<String,?> env = new HashMap<String,Object>(); FileSystems.newFileSystem(zipfile, null).close(); // Test: FileSystems#newFileSystem(URI) URI uri = new URI("jar", zipfile.toUri().toString(), null); FileSystem fs = FileSystems.newFileSystem(uri, env, null); // Test: exercise toUri method String expected = uri.toString() + "!/foo"; String actual = fs.getPath("/foo").toUri().toString(); if (!actual.equals(expected)) { throw new RuntimeException("toUri returned '" + actual + "', expected '" + expected + "'"); } // Test: exercise directory iterator and retrieval of basic attributes Files.walkFileTree(fs.getPath("/"), new FileTreePrinter()); // Test: DirectoryStream found = false; try (DirectoryStream<Path> stream = Files.newDirectoryStream(fs.getPath("/"))) { for (Path entry: stream) { found = entry.toString().equals("/META-INF/"); if (found) break; } } if (!found) throw new RuntimeException("Expected file not found"); // Test: copy file from zip file to current (scratch) directory Path source = fs.getPath("/META-INF/services/java.nio.file.spi.FileSystemProvider"); if (Files.exists(source)) { Path target = Paths.get(source.getFileName().toString()); Files.copy(source, target, StandardCopyOption.REPLACE_EXISTING); try { long s1 = Files.readAttributes(source, BasicFileAttributes.class).size(); long s2 = Files.readAttributes(target, BasicFileAttributes.class).size(); if (s2 != s1) throw new RuntimeException("target size != source size"); } finally { Files.delete(target); } } // Test: FileStore FileStore store = Files.getFileStore(fs.getPath("/")); if (!store.supportsFileAttributeView("basic")) throw new RuntimeException("BasicFileAttributeView should be supported"); // Test: ClosedFileSystemException fs.close(); if (fs.isOpen()) throw new RuntimeException("FileSystem should be closed"); try { fs.provider().checkAccess(fs.getPath("/missing"), AccessMode.READ); } catch (ClosedFileSystemException x) { } }
Example 11
Source File: FileSystemsTest.java From openjdk-systemtest with Apache License 2.0 | 4 votes |
public void testFileSystemIsRegistered() throws URISyntaxException { // Check that the expected "memory0" FileSystem is available boolean foundInitialProvider = false; for (FileSystemProvider provider: FileSystemProvider.installedProviders()) { if (provider.getScheme().equalsIgnoreCase("memory0")) { foundInitialProvider = true; } } assertTrue("Unable to find intial provider 'memory0'", foundInitialProvider); FileSystem memoryFileSystem = FileSystems.getFileSystem(new URI("memory0:///")); assertNotNull("Returned memoryFileSystem for 'memory0:///' was null", memoryFileSystem); String filename = "bargh"; assertNotNull("Returned filename for 'memory0:///"+filename+"' was null", memoryFileSystem.getPath(filename)); assertEquals("MemoryFileSystem did not return the expected string representation", "/memory/" + filename, memoryFileSystem.getPath(filename).toString()); }
Example 12
Source File: Basic.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { Path zipfile = Paths.get(args[0]); // Test: zip should should be returned in provider list boolean found = false; for (FileSystemProvider provider: FileSystemProvider.installedProviders()) { if (provider.getScheme().equalsIgnoreCase("jar")) { found = true; break; } } if (!found) throw new RuntimeException("'jar' provider not installed"); // Test: FileSystems#newFileSystem(Path) Map<String,?> env = new HashMap<String,Object>(); FileSystems.newFileSystem(zipfile, null).close(); // Test: FileSystems#newFileSystem(URI) URI uri = new URI("jar", zipfile.toUri().toString(), null); FileSystem fs = FileSystems.newFileSystem(uri, env, null); // Test: exercise toUri method String expected = uri.toString() + "!/foo"; String actual = fs.getPath("/foo").toUri().toString(); if (!actual.equals(expected)) { throw new RuntimeException("toUri returned '" + actual + "', expected '" + expected + "'"); } // Test: exercise directory iterator and retrieval of basic attributes Files.walkFileTree(fs.getPath("/"), new FileTreePrinter()); // Test: DirectoryStream found = false; try (DirectoryStream<Path> stream = Files.newDirectoryStream(fs.getPath("/"))) { for (Path entry: stream) { found = entry.toString().equals("/META-INF/"); if (found) break; } } if (!found) throw new RuntimeException("Expected file not found"); // Test: copy file from zip file to current (scratch) directory Path source = fs.getPath("/META-INF/services/java.nio.file.spi.FileSystemProvider"); if (Files.exists(source)) { Path target = Paths.get(source.getFileName().toString()); Files.copy(source, target, StandardCopyOption.REPLACE_EXISTING); try { long s1 = Files.readAttributes(source, BasicFileAttributes.class).size(); long s2 = Files.readAttributes(target, BasicFileAttributes.class).size(); if (s2 != s1) throw new RuntimeException("target size != source size"); } finally { Files.delete(target); } } // Test: FileStore FileStore store = Files.getFileStore(fs.getPath("/")); if (!store.supportsFileAttributeView("basic")) throw new RuntimeException("BasicFileAttributeView should be supported"); // Test: ClosedFileSystemException fs.close(); if (fs.isOpen()) throw new RuntimeException("FileSystem should be closed"); try { fs.provider().checkAccess(fs.getPath("/missing"), AccessMode.READ); } catch (ClosedFileSystemException x) { } }
Example 13
Source File: Basic.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { Path zipfile = Paths.get(args[0]); // Test: zip should should be returned in provider list boolean found = false; for (FileSystemProvider provider: FileSystemProvider.installedProviders()) { if (provider.getScheme().equalsIgnoreCase("jar")) { found = true; break; } } if (!found) throw new RuntimeException("'jar' provider not installed"); // Test: FileSystems#newFileSystem(Path) Map<String,?> env = new HashMap<String,Object>(); FileSystems.newFileSystem(zipfile, null).close(); // Test: FileSystems#newFileSystem(URI) URI uri = new URI("jar", zipfile.toUri().toString(), null); FileSystem fs = FileSystems.newFileSystem(uri, env, null); // Test: exercise toUri method String expected = uri.toString() + "!/foo"; String actual = fs.getPath("/foo").toUri().toString(); if (!actual.equals(expected)) { throw new RuntimeException("toUri returned '" + actual + "', expected '" + expected + "'"); } // Test: exercise directory iterator and retrieval of basic attributes Files.walkFileTree(fs.getPath("/"), new FileTreePrinter()); // Test: DirectoryStream found = false; try (DirectoryStream<Path> stream = Files.newDirectoryStream(fs.getPath("/"))) { for (Path entry: stream) { found = entry.toString().equals("/META-INF/"); if (found) break; } } if (!found) throw new RuntimeException("Expected file not found"); // Test: copy file from zip file to current (scratch) directory Path source = fs.getPath("/META-INF/services/java.nio.file.spi.FileSystemProvider"); if (Files.exists(source)) { Path target = Paths.get(source.getFileName().toString()); Files.copy(source, target, StandardCopyOption.REPLACE_EXISTING); try { long s1 = Files.readAttributes(source, BasicFileAttributes.class).size(); long s2 = Files.readAttributes(target, BasicFileAttributes.class).size(); if (s2 != s1) throw new RuntimeException("target size != source size"); } finally { Files.delete(target); } } // Test: FileStore FileStore store = Files.getFileStore(fs.getPath("/")); if (!store.supportsFileAttributeView("basic")) throw new RuntimeException("BasicFileAttributeView should be supported"); // Test: ClosedFileSystemException fs.close(); if (fs.isOpen()) throw new RuntimeException("FileSystem should be closed"); try { fs.provider().checkAccess(fs.getPath("/missing"), AccessMode.READ); } catch (ClosedFileSystemException x) { } }
Example 14
Source File: FileSystems.java From jdk8u60 with GNU General Public License v2.0 | 3 votes |
/** * Returns a reference to an existing {@code FileSystem}. * * <p> This method iterates over the {@link FileSystemProvider#installedProviders() * installed} providers to locate the provider that is identified by the URI * {@link URI#getScheme scheme} of the given URI. URI schemes are compared * without regard to case. The exact form of the URI is highly provider * dependent. If found, the provider's {@link FileSystemProvider#getFileSystem * getFileSystem} method is invoked to obtain a reference to the {@code * FileSystem}. * * <p> Once a file system created by this provider is {@link FileSystem#close * closed} it is provider-dependent if this method returns a reference to * the closed file system or throws {@link FileSystemNotFoundException}. * If the provider allows a new file system to be created with the same URI * as a file system it previously created then this method throws the * exception if invoked after the file system is closed (and before a new * instance is created by the {@link #newFileSystem newFileSystem} method). * * <p> 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 {@link FileSystems#getDefault * default} file system, no permission check is required. * * @param uri the URI to locate the file system * * @return the reference to the file system * * @throws IllegalArgumentException * if the pre-conditions for the {@code uri} parameter are not met * @throws FileSystemNotFoundException * if the file system, identified by the URI, does not exist * @throws ProviderNotFoundException * if a provider supporting the URI scheme is not installed * @throws SecurityException * if a security manager is installed and it denies an unspecified * permission */ public static FileSystem getFileSystem(URI uri) { String scheme = uri.getScheme(); for (FileSystemProvider provider: FileSystemProvider.installedProviders()) { if (scheme.equalsIgnoreCase(provider.getScheme())) { return provider.getFileSystem(uri); } } throw new ProviderNotFoundException("Provider \"" + scheme + "\" not found"); }
Example 15
Source File: FileSystems.java From TencentKona-8 with GNU General Public License v2.0 | 3 votes |
/** * Returns a reference to an existing {@code FileSystem}. * * <p> This method iterates over the {@link FileSystemProvider#installedProviders() * installed} providers to locate the provider that is identified by the URI * {@link URI#getScheme scheme} of the given URI. URI schemes are compared * without regard to case. The exact form of the URI is highly provider * dependent. If found, the provider's {@link FileSystemProvider#getFileSystem * getFileSystem} method is invoked to obtain a reference to the {@code * FileSystem}. * * <p> Once a file system created by this provider is {@link FileSystem#close * closed} it is provider-dependent if this method returns a reference to * the closed file system or throws {@link FileSystemNotFoundException}. * If the provider allows a new file system to be created with the same URI * as a file system it previously created then this method throws the * exception if invoked after the file system is closed (and before a new * instance is created by the {@link #newFileSystem newFileSystem} method). * * <p> 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 {@link FileSystems#getDefault * default} file system, no permission check is required. * * @param uri the URI to locate the file system * * @return the reference to the file system * * @throws IllegalArgumentException * if the pre-conditions for the {@code uri} parameter are not met * @throws FileSystemNotFoundException * if the file system, identified by the URI, does not exist * @throws ProviderNotFoundException * if a provider supporting the URI scheme is not installed * @throws SecurityException * if a security manager is installed and it denies an unspecified * permission */ public static FileSystem getFileSystem(URI uri) { String scheme = uri.getScheme(); for (FileSystemProvider provider: FileSystemProvider.installedProviders()) { if (scheme.equalsIgnoreCase(provider.getScheme())) { return provider.getFileSystem(uri); } } throw new ProviderNotFoundException("Provider \"" + scheme + "\" not found"); }
Example 16
Source File: FileSystems.java From openjdk-jdk8u with GNU General Public License v2.0 | 3 votes |
/** * Returns a reference to an existing {@code FileSystem}. * * <p> This method iterates over the {@link FileSystemProvider#installedProviders() * installed} providers to locate the provider that is identified by the URI * {@link URI#getScheme scheme} of the given URI. URI schemes are compared * without regard to case. The exact form of the URI is highly provider * dependent. If found, the provider's {@link FileSystemProvider#getFileSystem * getFileSystem} method is invoked to obtain a reference to the {@code * FileSystem}. * * <p> Once a file system created by this provider is {@link FileSystem#close * closed} it is provider-dependent if this method returns a reference to * the closed file system or throws {@link FileSystemNotFoundException}. * If the provider allows a new file system to be created with the same URI * as a file system it previously created then this method throws the * exception if invoked after the file system is closed (and before a new * instance is created by the {@link #newFileSystem newFileSystem} method). * * <p> 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 {@link FileSystems#getDefault * default} file system, no permission check is required. * * @param uri the URI to locate the file system * * @return the reference to the file system * * @throws IllegalArgumentException * if the pre-conditions for the {@code uri} parameter are not met * @throws FileSystemNotFoundException * if the file system, identified by the URI, does not exist * @throws ProviderNotFoundException * if a provider supporting the URI scheme is not installed * @throws SecurityException * if a security manager is installed and it denies an unspecified * permission */ public static FileSystem getFileSystem(URI uri) { String scheme = uri.getScheme(); for (FileSystemProvider provider: FileSystemProvider.installedProviders()) { if (scheme.equalsIgnoreCase(provider.getScheme())) { return provider.getFileSystem(uri); } } throw new ProviderNotFoundException("Provider \"" + scheme + "\" not found"); }
Example 17
Source File: FileSystems.java From jdk8u_jdk with GNU General Public License v2.0 | 3 votes |
/** * Returns a reference to an existing {@code FileSystem}. * * <p> This method iterates over the {@link FileSystemProvider#installedProviders() * installed} providers to locate the provider that is identified by the URI * {@link URI#getScheme scheme} of the given URI. URI schemes are compared * without regard to case. The exact form of the URI is highly provider * dependent. If found, the provider's {@link FileSystemProvider#getFileSystem * getFileSystem} method is invoked to obtain a reference to the {@code * FileSystem}. * * <p> Once a file system created by this provider is {@link FileSystem#close * closed} it is provider-dependent if this method returns a reference to * the closed file system or throws {@link FileSystemNotFoundException}. * If the provider allows a new file system to be created with the same URI * as a file system it previously created then this method throws the * exception if invoked after the file system is closed (and before a new * instance is created by the {@link #newFileSystem newFileSystem} method). * * <p> 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 {@link FileSystems#getDefault * default} file system, no permission check is required. * * @param uri the URI to locate the file system * * @return the reference to the file system * * @throws IllegalArgumentException * if the pre-conditions for the {@code uri} parameter are not met * @throws FileSystemNotFoundException * if the file system, identified by the URI, does not exist * @throws ProviderNotFoundException * if a provider supporting the URI scheme is not installed * @throws SecurityException * if a security manager is installed and it denies an unspecified * permission */ public static FileSystem getFileSystem(URI uri) { String scheme = uri.getScheme(); for (FileSystemProvider provider: FileSystemProvider.installedProviders()) { if (scheme.equalsIgnoreCase(provider.getScheme())) { return provider.getFileSystem(uri); } } throw new ProviderNotFoundException("Provider \"" + scheme + "\" not found"); }
Example 18
Source File: FileSystems.java From openjdk-8-source with GNU General Public License v2.0 | 3 votes |
/** * Returns a reference to an existing {@code FileSystem}. * * <p> This method iterates over the {@link FileSystemProvider#installedProviders() * installed} providers to locate the provider that is identified by the URI * {@link URI#getScheme scheme} of the given URI. URI schemes are compared * without regard to case. The exact form of the URI is highly provider * dependent. If found, the provider's {@link FileSystemProvider#getFileSystem * getFileSystem} method is invoked to obtain a reference to the {@code * FileSystem}. * * <p> Once a file system created by this provider is {@link FileSystem#close * closed} it is provider-dependent if this method returns a reference to * the closed file system or throws {@link FileSystemNotFoundException}. * If the provider allows a new file system to be created with the same URI * as a file system it previously created then this method throws the * exception if invoked after the file system is closed (and before a new * instance is created by the {@link #newFileSystem newFileSystem} method). * * <p> 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 {@link FileSystems#getDefault * default} file system, no permission check is required. * * @param uri the URI to locate the file system * * @return the reference to the file system * * @throws IllegalArgumentException * if the pre-conditions for the {@code uri} parameter are not met * @throws FileSystemNotFoundException * if the file system, identified by the URI, does not exist * @throws ProviderNotFoundException * if a provider supporting the URI scheme is not installed * @throws SecurityException * if a security manager is installed and it denies an unspecified * permission */ public static FileSystem getFileSystem(URI uri) { String scheme = uri.getScheme(); for (FileSystemProvider provider: FileSystemProvider.installedProviders()) { if (scheme.equalsIgnoreCase(provider.getScheme())) { return provider.getFileSystem(uri); } } throw new ProviderNotFoundException("Provider \"" + scheme + "\" not found"); }
Example 19
Source File: FileSystems.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 3 votes |
/** * Returns a reference to an existing {@code FileSystem}. * * <p> This method iterates over the {@link FileSystemProvider#installedProviders() * installed} providers to locate the provider that is identified by the URI * {@link URI#getScheme scheme} of the given URI. URI schemes are compared * without regard to case. The exact form of the URI is highly provider * dependent. If found, the provider's {@link FileSystemProvider#getFileSystem * getFileSystem} method is invoked to obtain a reference to the {@code * FileSystem}. * * <p> Once a file system created by this provider is {@link FileSystem#close * closed} it is provider-dependent if this method returns a reference to * the closed file system or throws {@link FileSystemNotFoundException}. * If the provider allows a new file system to be created with the same URI * as a file system it previously created then this method throws the * exception if invoked after the file system is closed (and before a new * instance is created by the {@link #newFileSystem newFileSystem} method). * * <p> 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 {@link FileSystems#getDefault * default} file system, no permission check is required. * * @param uri the URI to locate the file system * * @return the reference to the file system * * @throws IllegalArgumentException * if the pre-conditions for the {@code uri} parameter are not met * @throws FileSystemNotFoundException * if the file system, identified by the URI, does not exist * @throws ProviderNotFoundException * if a provider supporting the URI scheme is not installed * @throws SecurityException * if a security manager is installed and it denies an unspecified * permission */ public static FileSystem getFileSystem(URI uri) { String scheme = uri.getScheme(); for (FileSystemProvider provider: FileSystemProvider.installedProviders()) { if (scheme.equalsIgnoreCase(provider.getScheme())) { return provider.getFileSystem(uri); } } throw new ProviderNotFoundException("Provider \"" + scheme + "\" not found"); }
Example 20
Source File: FileSystems.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 3 votes |
/** * Returns a reference to an existing {@code FileSystem}. * * <p> This method iterates over the {@link FileSystemProvider#installedProviders() * installed} providers to locate the provider that is identified by the URI * {@link URI#getScheme scheme} of the given URI. URI schemes are compared * without regard to case. The exact form of the URI is highly provider * dependent. If found, the provider's {@link FileSystemProvider#getFileSystem * getFileSystem} method is invoked to obtain a reference to the {@code * FileSystem}. * * <p> Once a file system created by this provider is {@link FileSystem#close * closed} it is provider-dependent if this method returns a reference to * the closed file system or throws {@link FileSystemNotFoundException}. * If the provider allows a new file system to be created with the same URI * as a file system it previously created then this method throws the * exception if invoked after the file system is closed (and before a new * instance is created by the {@link #newFileSystem newFileSystem} method). * * <p> 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 {@link FileSystems#getDefault * default} file system, no permission check is required. * * @param uri the URI to locate the file system * * @return the reference to the file system * * @throws IllegalArgumentException * if the pre-conditions for the {@code uri} parameter are not met * @throws FileSystemNotFoundException * if the file system, identified by the URI, does not exist * @throws ProviderNotFoundException * if a provider supporting the URI scheme is not installed * @throws SecurityException * if a security manager is installed and it denies an unspecified * permission */ public static FileSystem getFileSystem(URI uri) { String scheme = uri.getScheme(); for (FileSystemProvider provider: FileSystemProvider.installedProviders()) { if (scheme.equalsIgnoreCase(provider.getScheme())) { return provider.getFileSystem(uri); } } throw new ProviderNotFoundException("Provider \"" + scheme + "\" not found"); }