I want to play a .wav file using java code which is in a jar file as resource. My code is look like this -
try {
URL defaultSound = getClass().getResou
this worked fine for me:
public void playSound() {
InputStream in;
try {
in = new BufferedInputStream(new FileInputStream(new File(
getClass().getClassLoader()
.getResource("com/kaito/resources/sound.wav").getPath())));
AudioStream audioStream = new AudioStream(in);
AudioPlayer.player.start(audioStream);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}