If the intention is to store the sound data in a byte[]
, the best approach is not to get an AudioInputStream
at all. Instead, just use a plain InputStream
.
The AudioInputStream
typically strips the first bytes from an input stream (because they contain formatting data) and then only provides the frames or samples of that stream. Doing it using an InputStream
on the other hand, you should be able to get all the bytes. Then once the entire data is in a byte array, an AudioInputStream
can be formed from the byte array (if needed).