Java FileStore get type, total space, used space, available space
import java.nio.file.FileStore; import java.nio.file.FileSystem; import java.nio.file.FileSystems; public class Main { public static void main(String[] args) throws Exception{ FileSystem fs = FileSystems.getDefault(); System.out.println("Read-only file system: " + fs.isReadOnly()); System.out.println("File name separator: " + fs.getSeparator()); System.out.println("\nAvailable file-stores are"); for (FileStore store : fs.getFileStores()) { String desc = store.toString(); String type = store.type(); System.out.println("type:"+type); long totalSpace = store.getTotalSpace(); long unallocatedSpace = store.getUnallocatedSpace(); long availableSpace = store.getUsableSpace(); System.out.println(desc + ", Total: " + totalSpace + ", Unallocated: " + unallocatedSpace + ", Available: " + availableSpace); }//from w w w . jav a 2 s. com } }