本文整理汇总了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();
}
}
示例2: close
import java.nio.file.FileSystem; //导入方法依赖的package包/类
@Override
public void close() throws IOException {
for (FileSystem fs : ctSym2FileSystem.values()) {
fs.close();
}
ctSym2FileSystem.clear();
}
示例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() + "\"");
}
}
示例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();
}
示例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");
}
}
}
}
示例6: close
import java.nio.file.FileSystem; //导入方法依赖的package包/类
@Override
public void close() throws IOException {
for (FileSystem fs: fileSystems.values())
fs.close();
}
示例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
}