title: FileInputStream to byte array in Android application
body: <p>I have a FileInputStream created using <code>Context.openFileInput()</code>. I now want to convert the file into a byte array. </p>
  
  <p>Unfortunately, I can't determine the size of the byte array required for <code>FileInputStream.read(byte[])</code>. The <code>available()</code> method doesn't work, and I can't create a File to check it's length using the specific pathname, probably because the path is inaccessible to non-root users.</p>
  
  <p>I read about <code>ByteArrayOutputStream</code>, and it seems to dynamically adjust the byte array size to fit, but I can't get how to read from the <code>FileInputStream</code> to write to the <code>ByteArrayOutputStream</code>. </p>