Source Code
File Name: TotalSpaceAndFreeSpaceDemo.java
import java.io.File;
public class TotalSpaceAndFreeSpaceDemo {
public static void main(String[] args){
File file = new File("D:");
long totalSpace = file.getTotalSpace();
System.out.println("Total space on drive " + file + " = " + totalSpace + "bytes");
// Check the free space in C:
long freeSpace = file.getFreeSpace();
System.out.println("Free space on drive " + file + " = " + freeSpace + "bytes");
}
}
Output
Total space on drive D: = 299266732032bytes Free space on drive D: = 38464524288bytes
Tidak ada komentar:
Posting Komentar