java - FileInputStream to byte array in Android application -


I have a FileInputStream that was created using context.openFileInput () . Now I want to convert the file into a byte array.

Unfortunately, I can not determine the size of required byte array for FileInputStream.read (byte []) . The available () method does not work, and I can not make a file to check length by using a specific pathname, possibly because the path is accessible to non-root users.

I have read about the

I have read about the

How can not read byteaututputstream by code>

This should work.

  InputStream = Context.openFileInput (someFileName); Bytereon OutputStream Boss = New Bytereunootstream (); Byte [] B = new byte [1024]; While ((Int bytes Reid = Reid (B))! = -1) {Bose. Written (b, 0, bytes read); } Byte [] bytes = boss Batteryre ();    

Comments