I have a FileInputStream created using Context.openFileInput()
. I now want to convert the file into a byte array.
Unfortunately, I can't determine the size of the byte array required for FileInputStream.read(byte[])
. The available()
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.
I read about ByteArrayOutputStream
, and it seems to dynamically adjust the byte array size to fit, but I can't get how to read from the FileInputStream
to write to the ByteArrayOutputStream
.