当前位置: 首页>>代码示例>>Java>>正文


Java FileSystemProvider.newFileSystem方法代码示例

本文整理汇总了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;
                        }
                    }
                });
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:JavacFileManager.java

示例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);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:11,代码来源:PassThroughFileSystem.java

示例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;
    }
 
开发者ID:advantageous,项目名称:boon,代码行数:31,代码来源:IO.java

示例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);
}
 
开发者ID:google,项目名称:jimfs,代码行数:6,代码来源:SystemJimfsFileSystemProvider.java


注:本文中的java.nio.file.spi.FileSystemProvider.newFileSystem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。