I\'m running Java on a Unix platform. How can I get a list of all mounted filesystems via the Java 1.6 API?
I\'ve tried File.listRoots()
but that return
OSHI (Operating System and Hardware Information library for Java) can be useful here: https://github.com/oshi/oshi.
Check out this code:
@Test
public void test() {
final SystemInfo systemInfo = new SystemInfo();
final OSFileStore[] fileStores = systemInfo.getOperatingSystem().getFileSystem().getFileStores();
Stream.of(fileStores)
.peek(fs ->{
System.out.println("name: "+fs.getName());
System.out.println("type: "+fs.getType() );
System.out.println("str: "+fs.toString() );
System.out.println("mount: "+fs.getMount());
System.out.println("...");
}).count();
}