本文整理汇总了Java中java.nio.file.spi.FileSystemProvider.installedProviders方法的典型用法代码示例。如果您正苦于以下问题:Java FileSystemProvider.installedProviders方法的具体用法?Java FileSystemProvider.installedProviders怎么用?Java FileSystemProvider.installedProviders使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.nio.file.spi.FileSystemProvider
的用法示例。
在下文中一共展示了FileSystemProvider.installedProviders方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initFileSystemProvider
import java.nio.file.spi.FileSystemProvider; //导入方法依赖的package包/类
/**
* Initialize the FileSystemProvider. This method should be called before
* system property os.name is set. See see bug 235739.
*/
private static void initFileSystemProvider() {
try {
FileSystemProvider.installedProviders();
new File(".").isFile();
} catch (Exception e) {
Logger.getLogger(NbKeymapTest.class.getName()).log(
Level.INFO, null, e);
}
}
示例2: getJarFSProvider
import java.nio.file.spi.FileSystemProvider; //导入方法依赖的package包/类
public synchronized FileSystemProvider getJarFSProvider() {
if (jarFSProvider != null) {
return jarFSProvider;
}
for (FileSystemProvider provider: FileSystemProvider.installedProviders()) {
if (provider.getScheme().equals("jar")) {
return (jarFSProvider = provider);
}
}
return null;
}
示例3: getJarFSProvider
import java.nio.file.spi.FileSystemProvider; //导入方法依赖的package包/类
private FileSystemProvider getJarFSProvider() throws IOException {
if (jarFSProvider != null) {
return jarFSProvider;
}
for (FileSystemProvider provider: FileSystemProvider.installedProviders()) {
if (provider.getScheme().equals("jar")) {
return (jarFSProvider = provider);
}
}
throw new ProviderNotFoundException("no provider found for .jar files");
}
示例4: main
import java.nio.file.spi.FileSystemProvider; //导入方法依赖的package包/类
public static void main(String[] args)
throws IOException {
// ftp localhost
// filedrop/filedrop
List<FileSystemProvider> providers = FileSystemProvider.installedProviders();
for (FileSystemProvider provider : providers)
System.out.println(provider);
}
示例5: isJarFileSystemAvailable
import java.nio.file.spi.FileSystemProvider; //导入方法依赖的package包/类
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;
}
示例6: loadFileSystemProvider
import java.nio.file.spi.FileSystemProvider; //导入方法依赖的package包/类
private static FileSystemProvider loadFileSystemProvider(String providerType) {
FileSystemProvider provider = null;
for ( FileSystemProvider p : FileSystemProvider.installedProviders() ) {
if ( providerType.equals(p.getScheme()) ) {
provider = p;
break;
}
}
return provider;
}
示例7: getInstance
import java.nio.file.spi.FileSystemProvider; //导入方法依赖的package包/类
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;
}
示例8: installedProviders
import java.nio.file.spi.FileSystemProvider; //导入方法依赖的package包/类
@Test
public void installedProviders() throws Exception {
for (FileSystemProvider provider : FileSystemProvider
.installedProviders()) {
if (provider instanceof BundleFileSystemProvider) {
assertSame(provider, BundleFileSystemProvider.getInstance());
return;
}
}
fail("Could not find BundleFileSystemProvider as installed provider");
}
示例9: getInstalledProvider
import java.nio.file.spi.FileSystemProvider; //导入方法依赖的package包/类
@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;
}
示例10: validateProviderLoaded
import java.nio.file.spi.FileSystemProvider; //导入方法依赖的package包/类
@Test
public void validateProviderLoaded() throws Exception {
List<FileSystemProvider> providers = FileSystemProvider.installedProviders();
int length = providers.stream().filter(x -> x instanceof HdfsFileSystemProvider).toArray().length;
Assert.assertEquals(1, length);
//FileSystem fs = FileSystems.getFileSystem(new URI("hdfs://hortonworks.com:9000"));
}
示例11: main
import java.nio.file.spi.FileSystemProvider; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
List<FileSystemProvider> providers = FileSystemProvider.installedProviders();
for (FileSystemProvider fsProvider : providers) {
System.out.println("sheme: '" + fsProvider.getScheme() + "', provider: " + fsProvider.getClass());
}
Path tmpFile = Files.createTempFile("", ".tmp");
Files.write(tmpFile, "Hello".getBytes());
Path jarFile = Files.createTempFile("", ".jar");
try(JarOutputStream outputStream = new JarOutputStream(Files.newOutputStream(jarFile))){
outputStream.putNextEntry(new ZipEntry(tmpFile.getFileName().toString()));
Files.copy(tmpFile, outputStream);
}
try(FileSystem fileSystem = createVirtualFS(jarFile)){
Iterable<Path> directories = fileSystem.getRootDirectories();
for (Path dir : directories) {
System.out.println("Reading dir: " + dir.toUri());
DirectoryStream<Path> stream = Files.newDirectoryStream(dir);
for (Path file : stream) {
System.out.println("Reading file: " + file.toUri());
System.out.println("\tfrom " + file.getFileSystem().provider().getClass());
System.out.print("Content: ");
Files.copy(file, System.out);
}
}
}
}
示例12: testAutoRegister
import java.nio.file.spi.FileSystemProvider; //导入方法依赖的package包/类
/**
* Check that a FileSystemProvider handle <code>hdfs</code> scheme.
*/
@Test
public void testAutoRegister() {
boolean found = false;
for (FileSystemProvider fp : FileSystemProvider.installedProviders())
if (fp.getScheme().equals(HadoopFileSystemProvider.SCHEME))
found = true;
// Check auto register of the provider
assertTrue(found);
}
示例13: defaultInstance
import java.nio.file.spi.FileSystemProvider; //导入方法依赖的package包/类
static DxFileSystemProvider defaultInstance() {
if( instance != null )
return instance;
for (FileSystemProvider provider : FileSystemProvider.installedProviders()) {
if ( provider instanceof DxFileSystemProvider ) {
return instance = (DxFileSystemProvider)provider;
}
}
return null;
}
示例14: getProvider
import java.nio.file.spi.FileSystemProvider; //导入方法依赖的package包/类
public static FileSystemProvider getProvider(String scheme) {
for (FileSystemProvider fsp : FileSystemProvider.installedProviders()) {
if (fsp.getScheme().equals(scheme)) {
return fsp;
}
}
throw new IllegalArgumentException("No provider found for scheme: " + scheme);
}
示例15: testFileSystemIsRegistered
import java.nio.file.spi.FileSystemProvider; //导入方法依赖的package包/类
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());
}