Java播放声音文件为什么总是出现异常?
importsun.audio.*;importjava.io.*;publicclassplaysound{publicstaticvoidmain(String[]a...
import sun.audio.*;
import java.io.*;
public class playsound {
public static void main(String[] args) {
try {
InputStream fileau =new FileInputStream("sound/msg.wav") ;
AudioStream as = new AudioStream(fileau);
AudioPlayer.player.start(as);
} catch (IOException e) {
e.printStackTrace();
}
}
}
总是出现下面的异常
java.io.IOException: could not create audio stream from input stream
at sun.audio.AudioStream.<init>(Unknown Source)
at package1.playsound.main(playsound.java:10) 展开
import java.io.*;
public class playsound {
public static void main(String[] args) {
try {
InputStream fileau =new FileInputStream("sound/msg.wav") ;
AudioStream as = new AudioStream(fileau);
AudioPlayer.player.start(as);
} catch (IOException e) {
e.printStackTrace();
}
}
}
总是出现下面的异常
java.io.IOException: could not create audio stream from input stream
at sun.audio.AudioStream.<init>(Unknown Source)
at package1.playsound.main(playsound.java:10) 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询