I've looked around on stack overflow, and a few other sites, but I can't really find anything helpful. I need to have code that can play an audio file that is inside the same as my Class.java file. In other words, I need it to play a file without typing in the exact location of the file, llike if I was sending it to a friend. Here is what I have:
import java.applet.*;
import java.net.*;
public class MainClass extends Applet {
public void init() {
try {
AudioClip clip = Applet.newAudioClip(
new URL(“file://C:/sound.wav”));
clip.play();
} catch (MalformedURLException murle) {
murle.printStackTrace();
}
}
But I can't get it to play from just anywhere, only that specific folder. Is there a way to do this without typing "URL" before the file location?