Top Description Fields Constructors Methods
org.apache.derby.iapi.services.io

public Class AccessibleByteArrayOutputStream

extends ByteArrayOutputStream
Class Inheritance
Imports
java.io.ByteArrayInputStream, .ByteArrayOutputStream, .IOException, .InputStream

This allows us to get to the byte array to go back and edit contents or get the array without having a copy made.

Since a copy is not made, users must be careful that no more writes are made to the stream if the array reference is handed off.

Users of this must make the modifications *before* the next write is done, and then release their hold on the array.

Field Summary

Inherited from java.io.ByteArrayOutputStream:
bufcount

Constructor Summary

AccessConstructor and Description
public
public

Method Summary

Modifier and TypeMethod and Description
public static InputStream

Returns:

InputStream against the raw data.
copyStream
(InputStream
InputStream to be copied
in
,
int
Initial size of the byte array
bufferSize
)

Copy an InputStream into an array of bytes and return an InputStream against those bytes.

public InputStream

Returns:

an InputStream wrapping the byte array
getInputStream
()

Return an InputStream that wraps the valid byte array.

public byte[]

Returns:

a byte array
getInternalByteArray
()

The caller promises to set their variable to null before any other calls to write to this stream are made.

public void
readFrom(InputStream
The stream to read
in
)

Read the complete contents of the passed input stream into this byte array.

Inherited from java.io.ByteArrayOutputStream:
closeresetsizetoByteArraytoStringtoStringtoStringtoStringwritewritewriteByteswriteTo

Constructor Detail

AccessibleByteArrayOutputStreamback to summary
public AccessibleByteArrayOutputStream()
AccessibleByteArrayOutputStreamback to summary
public AccessibleByteArrayOutputStream(int size)

Method Detail

copyStreamback to summary
public static InputStream copyStream(InputStream in, int bufferSize) throws IOException

Copy an InputStream into an array of bytes and return an InputStream against those bytes. The input stream is copied until EOF is returned. This is useful to provide streams to applications in order to isolate them from Derby's internals.

Parameters
in:InputStream

InputStream to be copied

bufferSize:int

Initial size of the byte array

Returns:InputStream

InputStream against the raw data.

Exceptions
IOException:
Error reading the stream
getInputStreamback to summary
public InputStream getInputStream()

Return an InputStream that wraps the valid byte array. Note that no copy is made of the byte array from the input stream, it is up to the caller to ensure the correct co-ordination.

Returns:InputStream

an InputStream wrapping the byte array

getInternalByteArrayback to summary
public byte[] getInternalByteArray()

The caller promises to set their variable to null before any other calls to write to this stream are made. Or promises to throw away references to the stream before passing the array reference out of its control.

Returns:byte[]

a byte array

readFromback to summary
public void readFrom(InputStream in) throws IOException

Read the complete contents of the passed input stream into this byte array.

Parameters
in:InputStream

The stream to read

Exceptions
IOException:
on error