Java FileSystem .getRootDirectories ()

Syntax

FileSystem.getRootDirectories() has the following syntax.

public abstract Iterable <Path> getRootDirectories()

Example

In the following code shows how to use FileSystem.getRootDirectories() method.


/*from   ww w  . jav  a  2s .  com*/
import java.nio.file.FileSystem;
import java.nio.file.FileSystems;
import java.nio.file.Path;


public class Main {

    public static void main(String[] args) {
      FileSystem fileSystem = FileSystems.getDefault();

        Iterable<Path> dirs = fileSystem.getRootDirectories();
        for (Path name : dirs) {
            System.out.println(name);
        }
    }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    java.nio.file »




DirectoryStream.Filter
Files
FileStore
FileSystem
FileVisitor
Path
Paths
WatchService