‘getFileSystem()’ method of FileSystemProvider class is
used to get an instance of FileSystem.
Example
FileSystem fileSystem =
fileSystemProviders.get(0).getFileSystem(URI.create("file:///"));
package com.sample.app; import java.net.URI; import java.nio.file.FileSystem; import java.nio.file.Path; import java.nio.file.spi.FileSystemProvider; import java.util.List; public class App { public static void main(String args[]) { List<FileSystemProvider> fileSystemProviders = FileSystemProvider.installedProviders(); FileSystem fileSystem = fileSystemProviders.get(0).getFileSystem(URI.create("file:///")); Iterable<Path> paths = fileSystem.getRootDirectories(); for (Path path : paths) { System.out.println(path); } } }
No comments:
Post a Comment