本文整理匯總了Java中java.nio.file.spi.FileSystemProvider.newFileSystem方法的典型用法代碼示例。如果您正苦於以下問題:Java FileSystemProvider.newFileSystem方法的具體用法?Java FileSystemProvider.newFileSystem怎麽用?Java FileSystemProvider.newFileSystem使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.nio.file.spi.FileSystemProvider
的用法示例。
在下文中一共展示了FileSystemProvider.newFileSystem方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: ArchiveContainer
import java.nio.file.spi.FileSystemProvider; //導入方法依賴的package包/類
public ArchiveContainer(Path archivePath) throws IOException, ProviderNotFoundException, SecurityException {
this.archivePath = archivePath;
if (multiReleaseValue != null && archivePath.toString().endsWith(".jar")) {
Map<String,String> env = Collections.singletonMap("multi-release", multiReleaseValue);
FileSystemProvider jarFSProvider = fsInfo.getJarFSProvider();
Assert.checkNonNull(jarFSProvider, "should have been caught before!");
this.fileSystem = jarFSProvider.newFileSystem(archivePath, env);
} else {
this.fileSystem = FileSystems.newFileSystem(archivePath, null);
}
packages = new HashMap<>();
for (Path root : fileSystem.getRootDirectories()) {
Files.walkFileTree(root, EnumSet.noneOf(FileVisitOption.class), Integer.MAX_VALUE,
new SimpleFileVisitor<Path>() {
@Override
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) {
if (isValid(dir.getFileName())) {
packages.put(new RelativeDirectory(root.relativize(dir).toString()), dir);
return FileVisitResult.CONTINUE;
} else {
return FileVisitResult.SKIP_SUBTREE;
}
}
});
}
}
示例2: create
import java.nio.file.spi.FileSystemProvider; //導入方法依賴的package包/類
/**
* Creates a new "pass through" file system. Useful for test environments
* where the provider might not be deployed.
*/
static FileSystem create() throws IOException {
FileSystemProvider provider = new PassThroughProvider();
Map<String,?> env = Collections.emptyMap();
URI uri = URI.create("pass:///");
return provider.newFileSystem(uri, env);
}
示例3: zipFileSystem
import java.nio.file.spi.FileSystemProvider; //導入方法依賴的package包/類
public static FileSystem zipFileSystem( URI fileJarURI ) {
final Map<String, Object> env = Maps.map( "create", ( Object ) "true" );
FileSystemProvider provider = loadFileSystemProvider("jar");
Exceptions.requireNonNull(provider, "Zip file provider not found");
FileSystem fs = null;
try {
fs = provider.getFileSystem( fileJarURI );
} catch ( Exception ex ) {
if ( provider != null ) {
try {
fs = provider.newFileSystem( fileJarURI, env );
} catch ( IOException ex2 ) {
Exceptions.handle( FileSystem.class,
Str.sputs("unable to load", fileJarURI, "as zip file system"),
ex2 );
}
}
}
Exceptions.requireNonNull(provider, "Zip file system was not found");
return fs;
}
示例4: newFileSystem
import java.nio.file.spi.FileSystemProvider; //導入方法依賴的package包/類
@Override
public FileSystem newFileSystem(Path path, Map<String, ?> env) throws IOException {
FileSystemProvider realProvider = path.getFileSystem().provider();
return realProvider.newFileSystem(path, env);
}