java inputstream to string back to file
<p>I am tryin to receive a file. I get the inputstream and convert it to string and pass it to my method. From there I want to convert it into a byte array and then back to the file. I'm not able to achieve this result. This is how I write the string to file:</p>

<pre><code>String result = convertStreamToString(is);
byte[] b = result.getBytes();
FileOutputStream fos = null;        
fos = new FileOutputStream("/sdcard/chats/ReceivedFile"); 

Log.i("IMSERVICE", "FILERECCC-1");       
if (b!= null) 
{  
    result = convertStreamToString(is);              
    result = result.replace("\n", ""); 
    Log.e("InputStream output","FILEREC");

    //IOUtils.copy(is,fos);

    byte[] buffer = new byte[1024]; 
    int length;     
    while ((length = b.length) &gt; 0)
    {     
        fos.write(buffer, 0, length);
    } 
</code></pre>

<p>Could anyone help?</p>
