本文整理汇总了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);
}