Check total free space computer partition java
If you want to check your local machine partition size using java program please use below sample java class:
- Sample java class:
package com.javahonk; import java.io.File; public class GetPartitionFreeSpace { public static void main(String[] args) { File file = new File("C:\\"); System.out.println("Total usable sapce GB: "+file.getUsableSpace()/1000000000); System.out.println("Total sapce GB: "+file.getTotalSpace()/1000000000); System.out.println("Total free sapce GB: "+file.getFreeSpace()/1000000000); } }
- Output:
For more information please refer oracle documentation here