|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.rim.device.api.io.IOUtilities
public class IOUtilities
Helper functions for I/O.
| Method Summary | ||
|---|---|---|
static byte[] |
streamToBytes(InputStream stream)
Reads all bytes from an InputStream and returns them in a
byte array. |
|
static byte[] |
streamToBytes(InputStream stream,
int increment)
Reads all bytes from an InputStream and returns them in a
byte array. |
|
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static byte[] streamToBytes(InputStream stream)
throws IOException
InputStream and returns them in a
byte array.
This method simply invokes IOUtilities.streamToBytes(InputStream, int) with
the given InputStream and increment==1024.
stream - the InputStream whose bytes to read; may be
null
byte array whose length is equal to
the number of bytes read from the given InputStream and
whose elements are those bytes; returns null if and only if
stream==null
IOException - if reading from stream throws it
public static byte[] streamToBytes(InputStream stream,
int increment)
throws IOException
InputStream and returns them in a
byte array.
This method repeatedly invokes InputStream.read(byte[], int, int)
on the given InputStream, reading a chunks of bytes whose
size is based on the value provided for increment. Once the
end of the stream is reached, a byte array containing the
bytes read is returned.
This method uses some VM optimizations to avoid repeatedly creating new arrays and is considered to be very efficient.
stream - the InputStream whose bytes to read; may be
nullincrement - the suggested number of bytes to read at a time
byte array whose length is equal to
the number of bytes read from the given InputStream and
whose elements are those bytes; returns null if and only if
stream==null
IOException - if reading from stream throws it
IllegalArgumentException - if increment is less than
or equal to 0 (zero)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
Copyright 1999-2011 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Java is a trademark of Oracle America Inc. in the US and other countries.
Legal