我试图播放一个简单的.wav
文件,但我收到错误"无法从输入网址获取音频输入流"
这是我的代码:
try {
URL url = this.getClass().getResource("click.wav");
if (url == null) {
System.err.println("Couldn't find the file");
}
else {
AudioInputStream audioIn = AudioSystem.getAudioInputStream(url);
Clip clip = AudioSystem.getClip();
clip.open(audioIn);
clip.start();
}
} catch (Exception e) {
System.err.println(e.getMessage());
}
我将文件click.wav
拖到我的项目中
答案 0 :(得分:1)
我清理了我的项目并且有效