Class BAAOutputStream
java.lang.Object
java.io.OutputStream
org.apache.axiom.attachments.utils.BAAOutputStream
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable,ReadFromSupport
BAAOutputStream is like a ByteArrayOutputStream.
A ByteArrayOutputStream stores the backing data in a byte[].
BAAOutputStream stores the backing data in a Array of
byte[]. Using several non-contiguous chunks reduces
memory copy and resizing.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuffers()intlength()longreadFrom(InputStream is, long maxRead) Read data from the given input stream and write it to this output stream.longreceive(InputStream is, long maxRead) voidwrite(byte[] b) voidwrite(byte[] b, int off, int len) voidwrite(int b) Methods inherited from class java.io.OutputStream
close, flush, nullOutputStream
-
Constructor Details
-
BAAOutputStream
public BAAOutputStream()
-
-
Method Details
-
write
- Overrides:
writein classOutputStream- Throws:
IOException
-
write
- Overrides:
writein classOutputStream- Throws:
IOException
-
write
- Specified by:
writein classOutputStream- Throws:
IOException
-
buffers
-
length
public int length() -
receive
- Parameters:
is- InputStream containing datamaxRead- the maximum number of bytes to receive- Returns:
- bytesReceived
- Throws:
IOException
-
readFrom
Description copied from interface:ReadFromSupportRead data from the given input stream and write it to this output stream. The method transfers data until one of the following conditions is met:- The end of the input stream is reached.
- The value of the
lengthargument is different from-1and the number of bytes transferred is equal tolength.
- Specified by:
readFromin interfaceReadFromSupport- Parameters:
is- An input stream to read data from. This method will not close the stream.maxRead- the number of bytes to transfer, or-1if the method should transfer data until the end of the input stream is reached- Returns:
- the number of bytes transferred
- Throws:
StreamCopyException
-