當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。