net.rim.device.api.io
Class NoCopyByteArrayOutputStream
java.lang.Object
|
+--java.io.OutputStream
|
+--java.io.ByteArrayOutputStream
|
+--net.rim.device.api.io.NoCopyByteArrayOutputStream
- public class NoCopyByteArrayOutputStream
- extends ByteArrayOutputStream
Byte array output stream that returns handle to the underlying data buffer,
not a copy.
This class acts exactly like a standard byte array output stream, with
two exceptions:
- You can build it using another buffer as initial contents.
- Invoking
getByteArray() retrieves a handle to the underlying data
buffer, and not a copy of that buffer.
|
Method Summary |
byte[] |
getByteArray()
Retrieves the underlying byte array used as this stream's buffer. |
NoCopyByteArrayOutputStream
public NoCopyByteArrayOutputStream()
- Creates a new NoCopyByteArrayOutputStream instance.
Builds a new byte array output stream with an initial buffer size of
32 bytes.
NoCopyByteArrayOutputStream
public NoCopyByteArrayOutputStream(byte[] buffer,
int offset)
- Creates a new NoCopyByteArrayOutputStream instance built from buffer.
- Parameters:
buffer - Byte array to share as output stream buffer.offset - Initial write position.
NoCopyByteArrayOutputStream
public NoCopyByteArrayOutputStream(int size)
- Creates a new NoCopyByteArrayOutputStream instance of initial size.
- Parameters:
size - Initial size for the buffer.
getByteArray
public byte[] getByteArray()
- Retrieves the underlying byte array used as this stream's buffer.
Unlike ByteArrayOutputStream.toByteArray(), this method does
not create a copy of the buffer. The returned byte array will
probably be bigger than the actual size of the output stream. Use
ByteArrayOutputStream.size() to get the actual size of the stream.
- Returns:
- This stream's current data buffer.
Copyright 1999-2007 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Copyright 1993-2003 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.