Android Unable to merge two wave files
<p>I am working in android. I want to merge two wave files and want to create third file. For this I create two input streams and then trying to write those input streams into one output stream file.</p>

<p>This is my code:-</p>

<pre><code> File file = new File("/sdcard/z.wav");
        File file1 = new File("/sdcard/zz.wav");
        InputStream is = new FileInputStream(file);
        InputStream is1 = new FileInputStream(file1);

        // Get the size of the file
        long length = file.length();
        long length1 = file1.length();


        // Create the byte array to hold the data
        byte[] bytes = new byte[(int)length];
        byte[] bytes1 = new byte[(int)length1];

        // Read in the bytes
        int offset = 0;
        int numRead = 0;
        while (offset &lt; (int)length &amp;&amp;( numRead=is.read(bytes, offset, bytes.length-offset)) &gt;= 0) {
            offset += numRead;
        }

        int offset1 = 0;
        int numRead1 = 0;
        while (offset1 &lt; (int)length1 &amp;&amp;( numRead1=is1.read(bytes1, offset1, bytes1.length-offset1)) &gt;= 0) {
            offset1 += numRead1;
        }





        FileOutputStream fos=new FileOutputStream("sdcard/guruu.wav");
        Log.v("Trying Activity","before first write");
        fos.write(bytes);

        fos.write(bytes1,0,bytes1.length);
        fos.write(bytes);
        fos.close();

        is.close();
        is1.close();
</code></pre>

<p>when I play output file guruu.wav then this only playing file of <strong>file1</strong>, it is not playing content of file2. Please suggest me what mistake I have done. Is any other way to do this ?</p>

<p>I am very new in this so please do not down vote it. </p>

<p>Thank you in advance. </p>
