Java File.getFreeSpace()
Syntax
File.getFreeSpace() has the following syntax.
public long getFreeSpace()
Example
In the following code shows how to use File.getFreeSpace() method.
/*www . ja v a 2 s .co m*/
import java.io.File;
public class Main {
public static void main(String[] args) throws Exception {
// create new files
File f = new File("c:/");
long size = f.getFreeSpace();
System.out.print(size);
}
}
The code above generates the following result.
Home »
Java Tutorial »
java.io »
Java Tutorial »
java.io »