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
。java.io.IOException:不支持标记/重置
我该如何解决这个问题?
泰,这个工作。我修改了这样的代码: 'BufferedInputStream myStream = new BufferedInputStream(getClass()。getResourceAsStream(“mySound.au”)); AudioInputStream audio2 = AudioSystem.getAudioInputStream(myStream);' 现在它工作=) P.S.如果有人可以格式化这个评论,它会很棒=/ – Crais 2011-04-03 15:05:17
这是什么标记/重置意味着什么?可以查找的流? @McDowell,你可以在你的答案中显示装饰的代码吗? – 2011-08-02 20:08:52
@Shurane - 标记/重置允许在调用重置时(通常通过从标记被调用时缓冲RAM中的数据)将“未读”数据流回到标记点。 – McDowell 2011-08-03 07:31:40