try {
//String location = dir1.getCanonicalPath()+"\\app_yamb_test1\\mySound.au";
//displayMessage(location);
AudioInputStream audio2 = AudioSystem.getAudioInputStream(getClass().getResourceAsStream("mySound.au"));
Clip clip2 = AudioSystem.getClip();
clip2.open(audio2);
clip2.start();
} catch (UnsupportedAudioFileException uae) {
System.out.println(uae);
JOptionPane.showMessageDialog(null, uae.toString());
} catch (IOException ioe) {
System.out.println("Couldn't find it");
JOptionPane.showMessageDialog(null, ioe.toString());
} catch (LineUnavailableException lua) {
System.out.println(lua);
JOptionPane.showMessageDialog(null, lua.toString());
}
当我从netbeans运行应用程序时,此代码可以正常工作。声音播放,也没有例外。但是,当我从dist文件夹运行它时,声音不播放,并且java.io.IOException: mark/reset not supported
在消息对话框中显示。
我怎样才能解决这个问题?
BufferedInputStream myStream = new BufferedInputStream(getClass().getResourceAsStream("mySound.au")); AudioInputStream audio2 = AudioSystem.getAudioInputStream(myStream);
现在可以正常工作=)PS,如果有人可以格式化此注释,那就太好了= /