How to get a byte array from FileInputStream without OutOfMemory error
<p>I have a FileInputStream which has 200MB of data. I have to retrieve the bytes from the input stream.</p>

<p>I'm using the below code to convert InputStream into byte array.</p>

<pre><code>private byte[] convertStreamToByteArray(InputStream inputStream) {
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    try {
        int i;
        while ((i = inputStream.read()) &gt; 0) {
            bos.write(i);
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
    return bos.toByteArray();
}
</code></pre>

<p>I'm getting OutOfMemory exception while coverting such a large data to a byte array. </p>

<p>Kindly let me know any possible solutions to convert InputStream to byte array.</p>
