本文整理匯總了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());
}