Java IO Tutorial - 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  w w w  .  ja va 2 s .  c  o m
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.