Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • 1
    Thank you. That doesn't solve the problem though, because I have to specify the length of the byte[] array before I supply it, and I can't get that from an InputStream. Any idea how I can work out the length of the data given the Uri? Commented Mar 13, 2010 at 11:10
  • You don't have to know the file size in advance. The proposed solution will work with any stream length. Commented Apr 10, 2013 at 14:11
  • why do we need to declare a buffer size? could w eput any length and if so, is there no way to put entire contents at once? Commented Aug 9, 2016 at 0:46
  • @AP257 I'm not sure if it helps, but to read the number of bytes from input stream you can call .available() method Commented Oct 15, 2019 at 13:36