Java FileSystem get root directory
import java.nio.file.FileSystem; import java.nio.file.FileSystems; import java.nio.file.Path; public class Main { public static void main(String[] args) throws Exception{ FileSystem fs = FileSystems.getDefault(); System.out.println("\nAvailable root directories are"); for (Path root : fs.getRootDirectories()) { System.out.println(root);// w ww.j a v a 2 s. co m } } }