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); |


Discussion
Comments for “InputStream to ByteArray on a BlackBerry”