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


Java FileSystem.close方法代码示例

本文整理汇总了Java中java.nio.file.FileSystem.close方法的典型用法代码示例。如果您正苦于以下问题:Java FileSystem.close方法的具体用法?Java FileSystem.close怎么用?Java FileSystem.close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.nio.file.FileSystem的用法示例。


在下文中一共展示了FileSystem.close方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: down

import java.nio.file.FileSystem; //导入方法依赖的package包/类
public synchronized void down(FileSystem fileSystem) throws IOException {
	if (!this.semaphores.containsKey(fileSystem)) {
		throw new IllegalArgumentException("No semaphore found for file system. Did you up it?");
	}
	Integer semaphore = this.semaphores.get(fileSystem);
	if (semaphore > 1) {
		this.semaphores.put(fileSystem, semaphore - 1);
	} else {
		this.semaphores.remove(fileSystem);
		fileSystem.close();
	}
}
 
开发者ID:maenu,项目名称:kowalski,代码行数:13,代码来源:FileSystemSynchronizer.java

示例2: close

import java.nio.file.FileSystem; //导入方法依赖的package包/类
@Override
public void close() throws IOException {
    for (FileSystem fs : ctSym2FileSystem.values()) {
        fs.close();
    }
    ctSym2FileSystem.clear();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:8,代码来源:JDKPlatformProvider.java

示例3: checkNoUOE

import java.nio.file.FileSystem; //导入方法依赖的package包/类
static void checkNoUOE() throws IOException, URISyntaxException {
    String dir = System.getProperty("test.dir", ".");
    String fileName = dir + File.separator + "foo.bar";
    Path path = Paths.get(fileName);
    Path file = Files.createFile(path);
    try {
        URI uri = new URI("jar", file.toUri().toString(), null);
        System.out.println(uri);
        FileSystem fs = FileSystems.newFileSystem(uri, new HashMap());
        fs.close();
    } catch (ProviderNotFoundException pnfe) {
        System.out.println("Expected ProviderNotFoundException caught: "
            + "\"" + pnfe.getMessage() + "\"");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:16,代码来源:Basic.java

示例4: main

import java.nio.file.FileSystem; //导入方法依赖的package包/类
public static void main(String[] args)
    throws IOException, URISyntaxException {
    String os = System.getProperty("os.name");
    FileSystem fs = FileSystems.getDefault();

    // close should throw UOE
    try {
        fs.close();
        throw new RuntimeException("UnsupportedOperationException expected");
    } catch (UnsupportedOperationException e) { }
    check(fs.isOpen(), "should be open");

    check(!fs.isReadOnly(), "should provide read-write access");

    check(fs.provider().getScheme().equals("file"),
        "should use 'file' scheme");

    // sanity check FileStores
    checkFileStores(fs);

    // sanity check supportedFileAttributeViews
    checkSupported(fs, "basic");
    if (os.equals("SunOS"))
        checkSupported(fs, "posix", "unix", "owner", "acl", "user");
    if (os.equals("Linux"))
        checkSupported(fs, "posix", "unix", "owner", "dos", "user");
    if (os.contains("OS X"))
        checkSupported(fs, "posix", "unix", "owner");
    if (os.equals("Windows"))
        checkSupported(fs, "owner", "dos", "acl", "user");

    // sanity check non-throwing of UnsupportedOperationException by
    // FileSystems.newFileSystem(URI, ..)
    checkNoUOE();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:36,代码来源:Basic.java

示例5: main

import java.nio.file.FileSystem; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    String javaHome = args[0];
    FileSystem fs = null;
    boolean isInstalled = false;
    if (args.length == 2) {
        fs = createFsByInstalledProvider();
        isInstalled = true;
    } else {
        fs = createFsWithURLClassloader(javaHome);
    }

    Path mods = fs.getPath("/modules");
    try (Stream<Path> stream = Files.walk(mods)) {
        stream.forEach(path -> {
            path.getFileName();
        });
    } finally {
        try {
            fs.close();
        } catch (UnsupportedOperationException e) {
            if (!isInstalled) {
                throw new RuntimeException(
                    "UnsupportedOperationException is thrown unexpectedly");
            }
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:28,代码来源:Main.java

示例6: close

import java.nio.file.FileSystem; //导入方法依赖的package包/类
@Override
public void close() throws IOException {
    for (FileSystem fs: fileSystems.values())
        fs.close();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:6,代码来源:JavacPathFileManager.java

示例7: testCloseFileSystem

import java.nio.file.FileSystem; //导入方法依赖的package包/类
@Test(expectedExceptions = UnsupportedOperationException.class)
public void testCloseFileSystem() throws Exception {
    FileSystem fs = FileSystems.getFileSystem(URI.create("jrt:/"));
    fs.close(); // should throw UOE
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:6,代码来源:Basic.java


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