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

前端 未结 7 2046
慢半拍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:17

    With Google Guava, you can use ByteStreams.toByteArray(InputStream) to get all the bytes in the input stream:

    InputStream is = ...;
    byte[] bytes = ByteStream.toByteArray(is);
    

提交回复
热议问题