我使用了WritetoFile()方法,因为我的单词数组使用blockingPlay,但是,当我在文件系统中播放文件thisisatest_pause.wav时,它只会播放数组中的最后一个单词,即“test”。完整的短语是“这是一个测试”,其中指定了暂停参数。这是代码
public void play(int pause, String filename, String path) throws InterruptedException {
// play the words in order
for (int i = 0; i < numWords; i++) {
myWordArray[i].blockingPlay();
Thread.sleep(pause);
try {
myWordArray[i].writeToFile("C:\\Users\\Justin\\Desktop\\JavaMedia\\thisisatest_pause.wav\\");
} catch (SoundException e){
System.out.println("Error" +e);
}
}
}
最佳答案
因为循环中的每次迭代都会将相同的文件名写入。
我不知道myWordArray [i]是什么类型的对象,但是我的灵通能力告诉我,writeToFile的实现将覆盖文件(如果已存在)。
关于java - 将(WAV)写入文件只能说一个字(最后一个字),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39886566/