how to play sound in java which not internally saved in java project? I have tried this code but it only work with the file compiled in java project.. I want to make the sound file directory apart from the java project.
private void sound (int s)
{
try {
Clip clip = AudioSystem.getClip();
AudioInputStream inputStream = AudioSystem.getAudioInputStream(Main.class.getResourceAsStream("Music/Sound"+s+".wav"));
clip.open(inputStream);
clip.start();
} catch (LineUnavailableException | UnsupportedAudioFileException | IOException e) {
System.err.println(e.getMessage());
}
}