제 프로그램에서 비명을 지르고있는 여성의 오디오 파일을 재생하려고합니다. sun.audio를 통해 간단한 코드를 사용하고 있지만 파일을 재생할 수 없습니다.자바를 통해 오디오 파일을 재생할 수 없습니다
File
를 사용하여 시도하고 있는지 확인 ...
package hauntedHouseAdventure;
import java.io.*;
import sun.audio.*;
public class AudioScreamer {
public static void main(String[] args)
throws Exception {`
// open the sound file as a Java input stream
String screamFile = " C:/Users//alan/Downloads/woman-scream-01.au";
InputStream in = new FileInputStream(screamFile);
// create an audiostream from the inputstream
AudioStream audioStream = new AudioStream(in);
// play the audio clip with the audioplayer class
AudioPlayer.player.start(audioStream);
}
}
내가지고있어 오류가 그냥 그래서 우리는이 질문을 닫을 수 있습니다
Exception in thread "main" java.io.FileNotFoundException: C:\Users\alan\Downloads\woman-scream-01.au (The filename, directory name, or volume label syntax is incorrect)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at hauntedHouseAdventure.AudioScreamer.main(AudioScreamer.java:19)
나는 예외가 합리적으로 명백하다고 생각했을 것이다 ... 파일이 존재하지 않는다. 파일을로드하기 전에'System.out.println ("Exists :"+ new File(). exists ("C : /Users/alan/Downloads/woman-scream-01.au));'을 추가해보십시오. 'true'라고 말하기를 원한다면 경로 이름에 "C : /"를 넣으면 효과가 있는지 없는지 확실하지 않다. – MadProgrammer
그리고 공간이되었다. 나는 어리석은 느낌이 든다. 무엇이 나를 트려 주 었는가, 명시된 파일이 존재하지 않는다는 이전의 오류가 있다는 것이었다. 나는 이것이 다른 오류라고 생각했다 .MadProgrammer의 도움에 감사드립니다. – user3092008