// you’re reading...

Asides

InputStream to ByteArray on a BlackBerry

A quick and easy method to read an InputStream to a byte array is available in the IOUtilities class of the BlackBerry API.  I didn’t check if this is available pre 4.6 or not, but it does exist in 4.6

To read an InputStream directly to a byte array you can do something like this:

1
2
3
FileConnector fconn = (FileConnector)Connector.open("testfile.txt");
InputStream inStream = fconn.openInputStream();
byte[] byteData = IOUtilities.streamToBytes(inStream);
Share this on:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Reddit
  • StumbleUpon
  • Tumblr
  • Twitter
  • Slashdot

Discussion

Comments for “InputStream to ByteArray on a BlackBerry”

blog comments powered by Disqus