Android - getting from a Uri to an InputStream to a byte array?

前端 未结 7 2040
慢半拍i
慢半拍i 2020-11-30 03:44

I\'m trying to get from an Android Uri to a byte array.

I have the following code, but it keeps telling me that the byte array is 61 bytes long, even though the fil

7条回答
  •  旧巷少年郎
    2020-11-30 04:27

    With Apache Commons, you can read all the bytes from a Stream thanks to IOUtils.toByteArray(InputStream) as next:

    byte[] recordData = IOUtils.toByteArray(inStream);
    

    download jar: http://commons.apache.org/io/download_io.cgi

提交回复
热议问题