Reputation: 33
I am writing a program, and one of the requirements is that data can only be accepted from a CD-R that has been finalized. I cannot for the life of me figure out how to accomplish this check in Java. Any help would be much appreciated!
Upvotes: 2
Views: 559
Reputation: 51445
When a CD is finalized, it reports zero free file space.
Since Java 1.6, the File class has a getFreeSpace method.
When I tried this code on my Windows C: drive, it returned 403,547,947,008.
package com.ggl.testing;
import java.io.File;
public class GetFreeSpace {
public static void main(String[] args) {
File file = new File("C:");
System.out.println(file.getFreeSpace());
}
}
Try it on your CD drive, and see if it returns zero or a number, for a finalized CD or a not finalized CD, respectively.
Upvotes: 1