Take the 2-minute tour ×

I'm reading a .wav file into a byte array with the following code.

AudioInputStream inputStream = 
    AudioSystem.getAudioInputStream(/*my .wav file */);
int numBytes = inputStream.available();
byte[] buffer = new byte[numBytes];
inputStream.read(buffer, 0, numBytes);

Is there a simple way to remove the .wav headers either before or after reading into the byte array?

share|improve this question

4 Answers 4

up vote 1 down vote accepted

Here is a good reference on the wave file format.

share|improve this answer
you have to identify the chunks and remove the headers. –  Peter Kofler Sep 17 '09 at 20:38

The data from the AudioInputStream read() method is already raw wav data. So there is no need to worry about the .wav header. If you do want to access the header stuff, you would use the AudioFormat object associated with this AudioInputStream.


BTW, unless your .wav file is really small, you won't get it all with a single read as you've done with your sample. You will have to put your reads in a while loop, as in the first code snippet in the above cited tutorial.

share|improve this answer
+1 for adding the only correct answer on this thread, as well as for spotting the problem with the read. –  Andrew Thompson Jun 20 '11 at 9:41

If correct the .wav header is 44 bytes long, so skip/remove the first 44 and there you have it.

Don't know for sure though.

share|improve this answer

Is a wav file header a fixed size? If so inputStream.skip?

share|improve this answer

Your Answer


