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!
Asked
Active
Viewed 537 times
2
-
Related: [How to find out when a disc (DVD) has been written/burned?](http://superuser.com/q/559031/305088) – rpax Nov 12 '15 at 18:11
-
1This isn't really what I was talking about, I do not really care WHEN the disk was burnt, I only care to check if it has been finalized so that data cannot be added onto it at a later date. Thanks for the related psot though. – jhorner13 Nov 12 '15 at 18:15
1 Answers
1
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.

Gilbert Le Blanc
- 50,182
- 6
- 67
- 111
-
-
Unfortunately both finalized CDs and non-finalized CDS report a disk space remaiing of zero, so this method will not work. – jhorner13 Nov 13 '15 at 12:03