File Class Enhancements : File « JDK 6 « Java






File Class Enhancements

 
import java.io.File;

public class DiskSpaceDemo {

  public static void main(String[] args) {
    File file = new File("C:");
    long totalSpace = file.getTotalSpace();
    System.out.println("Total space on " + file + " = " + totalSpace + "bytes");

    // Check the free space in C:
    long freeSpace = file.getFreeSpace();
    System.out.println("Free space on " + file + " = " + freeSpace + "bytes");
  }
}
//Total space on C: = 40015953920bytes
//Free space on C: = 6470483968bytes

        








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.Get the total space
6.Creates a file and sets it to read-only.
7.Create a file and change its attribute to readonly