Java - converting byte array of audio into integer array
<p>I need to pass audio data into a 3rd party system as a "16bit integer array" (from the limited documentation I have).</p>

<p>This is what I've tried so far (the system reads it in from the resulting bytes.dat file).</p>

<pre><code>    AudioInputStream inputStream = AudioSystem.getAudioInputStream(new File("c:\\all.wav"));
    int numBytes = inputStream.available();
    byte[] buffer = new byte[numBytes];
    inputStream.read(buffer, 0, numBytes);

    BufferedWriter fileOut = new BufferedWriter(new FileWriter(new File("c:\\temp\\bytes.dat")));

    ByteBuffer bb = ByteBuffer.wrap(buffer);

    while (bb.remaining() &gt; 1) {
        short current = bb.getShort();
        fileOut.write(String.valueOf(current));
        fileOut.newLine();
    }
</code></pre>

<p>This doesn't seem to work - the 3rd party system doesn't recognise it and I also can't import the file into Audacity as raw audio.</p>

<p>Is there anything obvious I'm doing wrong, or is there a better way to do it?</p>

<p>Extra info: the wave file is 16bit, 44100Hz, mono.</p>
