Sunday 16 June 2019

FileSystem: getFileSystem: Get FileSystem for given scheme


'getFileSystem' method is used to get the FileSystem instance for given scheme.

Example
FileSystem fileSystem = FileSystems.getFileSystem(URI.create("file:///"));

App.java

package com.sample.app;

import java.net.URI;
import java.nio.file.FileSystem;
import java.nio.file.FileSystems;
import java.nio.file.Path;

public class App {

 public static void main(String args[]) {

  FileSystem fileSystem = FileSystems.getFileSystem(URI.create("file:///"));

  Iterable<Path> paths = fileSystem.getRootDirectories();

  for (Path path : paths) {
   System.out.println(path);
  }
 }
}



Previous                                                 Next                                                 Home

No comments:

Post a Comment