I am trying to write a simple sound ripper that I can use to find out how excellent CODEC works, but I got stuck in the first step, I can not get my program to read from the CD, the following code is what I tried to use
import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.RandomAccessFile; import java.util.Scanner; public class learning { public static void main(String[] args) throws IOException { File cd = new File( "/dev/sr0" ); RandomAccessFile rawAccess = new RandomAccessFile( cd, "r" ); byte[] content = new byte[20]; rawAccess.seek(19613); rawAccess.readFully(content); System.out.println(content); } }
but he gives me the following error
Exception in thread "main" java.io.IOException: Input/output error at java.io.RandomAccessFile.readBytes(Native Method) at java.io.RandomAccessFile.read(RandomAccessFile.java:355) at java.io.RandomAccessFile.readFully(RandomAccessFile.java:414) at java.io.RandomAccessFile.readFully(RandomAccessFile.java:394) at learning.main(learning.java:21)
and I canβt understand why I understood it, although maby RandomFileAccess was not a suitable class to use, but the only thing I could find was to say that this should work
Any help on reading a CD from java would be greatly appreciated.
Cheers Daniel
source share