I made a program to read audio files.
At first I did it with absolute path because it's easyer to develop.
Then I cahnge it to relative path because I want to compress it to a *jar
.
So I code this method(at first only short later the code:
1.: at first I make a FileArray to save the Files
2.: make the array to save the AudioClip
3.: for loop to read the Clips
Now the code:
private AudioClip[] liesAudioDateien (File inputFile) {
File[] dateFileArray;
AudioClip[] tracks;
dateFileArray = inputFile.listFiles();
tracks = new AudioClip[dateFileArray.length];
for (int i = 0; i < tracks.length; i++) {
if (dateFileArray[i].isFile()) {
try {
tracks[i] = Applet.newAudioClip(dateFileArray[i].toURL());
} catch (IOException ex) {
System.err.println("Error!: -- " + ex.toString());
}
}
}
return tracks;
}
inputFile.listfiles()
returns null, as seems my path isn't OK.
But my path is Ok, because I let it print on the command line.
D:\Eclipse\MyProjekt\dist\MyProject.jar\audio
.
In NetBeans, it does work. If I make a jar file, it doesn't work.
I have already try:
D:\Eclipse\MyProjekt\dist\MyProject.jar\audio\
/
in place of\