Get the total space : File « JDK 6 « Java






Get the total space

 


import java.io.File;

public class SpaceChecker {
  public static void main(String[] args) {
    File[] roots = File.listRoots();

    for (int i = 0; i < roots.length; i++) {
      System.out.println(roots[i]);
      System.out.println("Total space = " + roots[i].getTotalSpace());
      System.out.println();
    }
  }
}

        








Related examples in the same category

1.List all roots
2.Getting a Proper URL from a File Object
3.Get the free space
4.Get the usable space
5.File Class Enhancements
6.Creates a file and sets it to read-only.
7.Create a file and change its attribute to readonly