File GetFreeSpace() Example
Returns the number of unallocated bytes in the partition
File class GetFreeSpace() method example. This example shows you how to use GetFreeSpace method.This method Returns the number of unallocated bytes in the partition named by this abstract path name.
Here is the code:-
/**
* @Program that Returns the number of unallocated bytes in the partition named
* by this abstract path name.
* GetFreeSpace.java
* Author:-RoseIndia Team
* Date:-30-May-2008
*/
import java.io.*;
public class GetFreeSpace {
public static void main(String[] args) throws IOException {
File f = new File("/home/girish/Desktop/g.txt");
if (f.exists()) {
long l = f.getFreeSpace();
System.out.println("number of unallocated bytes is: " + l);
} else {
System.out.println("File does not exists");
}
}
} |
Output of the Program
| number of unallocated bytes is: 36247068672 |
|