I have a FileInputStream created using Context.openFileInput(). I now want to convert the file into a byte array.
Context.openFileInput()
Unfortunately, I can\'t determine the
This should work.
InputStream is = Context.openFileInput(someFileName); ByteArrayOutputStream bos = new ByteArrayOutputStream(); byte[] b = new byte[1024]; while ((int bytesRead = is.read(b)) != -1) { bos.write(b, 0, bytesRead); } byte[] bytes = bos.toByteArray();