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