So, I am to write a copy of the sound that I manipulated into a playable format, but whenever I try it, the files are very small (< 1kb), and they don't play, most likely because it is not readable data. Here is the code
public void play(int pause, String filename, String path) throws InterruptedException {
for (int i =0; i < numWords; i++) {
myWordArray[i].blockingPlay();
Thread.sleep(pause); // 300 m.seconds, as listed in main method parameter
File file = new File(path, filename);
try{
PrintWriter output = new PrintWriter(file);
output.println(myWordArray[i]);
output.close();
} catch(IOException ex) {
System.out.printf("ERROR: %s\n", ex);
}
}
}
I'm guessing PrintWriter only works for strings, which is why my WAV file is getting corrupted when I try to play? What should I substitute for this?
EDIT-
So, using the guides posted in the comments, I modified the code, however, now it does not create a file at all. Here is the code in my audio class...
public void play(int pause, String filename, String path) throws InterruptedException {
for (int i =0; i < numWords; i++) {
myWordArray[i].blockingPlay();
Thread.sleep(pause); // 300 m.seconds, as listed in main method parameter
File file = new File("C:\\Users\\Justin\\Desktop\\JavaMedia\\", "thisisatest.wav");
try{
InputStream fis = new FileInputStream(file);
byte[] buffer = new byte[(int)file.length()];
fis.read(buffer, 0, buffer.length);
fis.close();
}
catch(IOException ex){
System.out.printf("ERROR: %s\n", ex);
}
}
}
Here is the call in my main...
myPoem.play(300,"thisisatest_pause.wav", "C:\\Users\\Justin\\Desktop\\JavaMedia\\");
I want the "thisisatest_pause.wav" to be the new file it creates, but it doesn't create one at all.