Below java code show how to get total space and free space
[java]
/****************************************************************************************
* Created on 08-2011 Copyright(c) https://kodehelp.com All Rights Reserved.
****************************************************************************************/
package com.kodehelp.javaio;
import java.io.File;
/**
* Created by https://kodehelp.com
* Date: 8/27/11
*/
public class TotalAndFreeSpace {
public static void main(String args[]){
File file = new File("C:");
//check total space in 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");
}
}
[/java]