danielbrthwt Posted October 13, 2012 Share Posted October 13, 2012 (edited) I thought that making some software that rips audio CD's and movies would be an interesting project, so to start i am trying to make something that takes the songs on a audio CD and saves to the hard rive as a WAV file, the only problem is that i cant seem to find much information on how to do this in Java and what i have found dosent, below is the code i have tried but when i run it i get access denied errors even when i run it as administrator import java.io.File;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( "D:" );RandomAccessFile rawAccess = new RandomAccessFile( cd, "r" );byte[] content = new byte[2352];rawAccess.readFully(content);System.out.println(content);}}[/CODE].And the error i get is[CODE]Exception in thread "main" java.io.FileNotFoundException: D: (Access is denied)at java.io.RandomAccessFile.open(Native Method)at java.io.RandomAccessFile.<init>(Unknown Source)at learning.main(learning.java:13)[/CODE]Is there any way to read from the CD drive in Windows/Linux using java ? Edited October 13, 2012 by danielbrthwt Quote Link to comment Share on other sites More sharing options...
digip Posted October 13, 2012 Share Posted October 13, 2012 (edited) I don't see why not, but you might need to tell Java to do something different with it, since its removable media, the mounting and reading of the data might be treated differently. I don't know much about Java, but the declaration of a new file as d: might also be part of the problem. File cd = new File( "D:" );[/CODE]I think if anything, you need to 1 change directory to D:, then list contents of D: and decide what file you want to copy, or, mount D: and then stream bit for bit the contents of the drive to the HDD as an ISO if ripping is what you are after vs just finding and copying one file off.There is a tool for doing this in Java, might shed some light on it, since usually they post the source code with it too on sourceforge - http://jiic.berlios.de/ might have bits of code you would or could reuse or rewrite, or just use in general to see how its done.By the way, CD and DVD roms, have different ways they can be written to them, like Jolient, and ISO standards, some like audio cd's that also have data partitions on them(who remembers those from back in the day, making a mucic cd that contained wallpapers and videos too), so reading from them might also need to know how to look up the redbook standard the disc was created with before you can read from it to then copy contents off of it.http://en.wikipedia....ok_(CD_standard)Im not sure how that applies with respect to DVD's or even Blueray, which probably have their own standards. Edited October 13, 2012 by digip Quote Link to comment Share on other sites More sharing options...
danielbrthwt Posted October 14, 2012 Author Share Posted October 14, 2012 (edited) The directory is D:, and i tried it the directory as \\.\D: because i read somewhere that that's how you are ment to access logical drives but that dident work ether it just said that the parameter was in correct for this line RandomAccessFile rawAccess = new RandomAccessFile( cd, "r" );[/CODE]i'm thinking that many the RandomFileAccess class cant access logical drives so ill have a look for a different class to read the data Edited October 14, 2012 by danielbrthwt Quote Link to comment Share on other sites More sharing options...
bobbyb1980 Posted October 14, 2012 Share Posted October 14, 2012 I'm still learning Java, but I agree with digi. First you should enumerate the contents of the directory, then pick and choose what to copy after that. I found a lot of code to do this on the internet. http://www.javabeat.net/2007/08/recursively-traversing-files-and-folders-using-java-file-api/ Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.