Android: Reading wav file and displaying its values
<p>Hi i'm trying to read the data in a wav file so that i can plot it as a waveform. Following is the code that i have tried:</p>

<pre><code>    try {
        RandomAccessFile file = new RandomAccessFile(myFile,"r");
        while(file.read()&gt;-1){
         byte b1 = (byte) file.read();
         byte b2 = (byte) file.read();
         Log.d(TAG,"DATA:"+ (double) (b2 &lt;&lt; 8 | b1 &amp; 0xFF) / 32767.0);
        }
        file.close();

    } catch (FileNotFoundException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }
</code></pre>

<p>My output is a value that ranges between -1 and +1 initially but later it gives only DATA:0 it seems like an infinite loop  and there is a force close. According to me the loop should terminate when the end of file is reached. Can anyone pls suggest some terminating condition for the loop. Please Help.... Thanks is advance...</p>
