public class ExposedByteArrayOutputStream
extends java.io.ByteArrayOutputStream
Constructor and Description |
---|
ExposedByteArrayOutputStream() |
ExposedByteArrayOutputStream(int size) |
Modifier and Type | Method and Description |
---|---|
Buffer |
getBuffer() |
int |
getCapacity() |
byte[] |
getRawBuffer() |
void |
reset()
Resets the
count field of this byte array output
stream to zero, so that all currently accumulated output in the
output stream is discarded. |
void |
reset(int max_size)
Resets count and creates a new buf if the current buf is > max_size.
|
int |
size()
Returns the current size of the buffer.
|
byte[] |
toByteArray()
Creates a newly allocated byte array.
|
java.lang.String |
toString()
Converts the buffer's contents into a string decoding bytes using the
platform's default character set.
|
java.lang.String |
toString(java.lang.String charsetName)
Converts the buffer's contents into a string by decoding the bytes using
the specified
charsetName . |
void |
write(byte[] b,
int off,
int len)
Writes
len bytes from the specified byte array
starting at offset off to this byte array output stream. |
void |
write(int b) |
void |
writeTo(java.io.OutputStream out)
Writes the complete contents of this byte array output stream to
the specified output stream argument, as if by calling the output
stream's write method using
out.write(buf, 0, count) . |
public ExposedByteArrayOutputStream()
public ExposedByteArrayOutputStream(int size)
public void reset(int max_size)
public byte[] getRawBuffer()
public Buffer getBuffer()
public int getCapacity()
public void write(int b)
write
in class java.io.ByteArrayOutputStream
public void write(byte[] b, int off, int len)
len
bytes from the specified byte array
starting at offset off
to this byte array output stream.write
in class java.io.ByteArrayOutputStream
b
- the data.off
- the start offset in the data.len
- the number of bytes to write.public void writeTo(java.io.OutputStream out) throws java.io.IOException
out.write(buf, 0, count)
.writeTo
in class java.io.ByteArrayOutputStream
out
- the output stream to which to write the data.java.io.IOException
- if an I/O error occurs.public void reset()
count
field of this byte array output
stream to zero, so that all currently accumulated output in the
output stream is discarded. The output stream can be used again,
reusing the already allocated buffer space.reset
in class java.io.ByteArrayOutputStream
ByteArrayInputStream.count
public byte[] toByteArray()
toByteArray
in class java.io.ByteArrayOutputStream
ByteArrayOutputStream.size()
public int size()
size
in class java.io.ByteArrayOutputStream
count
field, which is the number
of valid bytes in this output stream.ByteArrayOutputStream.count
public java.lang.String toString()
This method always replaces malformed-input and unmappable-character sequences with the default replacement string for the platform's default character set. The CharsetDecoder class should be used when more control over the decoding process is required.
toString
in class java.io.ByteArrayOutputStream
public java.lang.String toString(java.lang.String charsetName) throws java.io.UnsupportedEncodingException
charsetName
. The length of
the new String is a function of the charset, and hence may not be
equal to the length of the byte array.
This method always replaces malformed-input and unmappable-character
sequences with this charset's default replacement string. The CharsetDecoder
class should be used when more control
over the decoding process is required.
toString
in class java.io.ByteArrayOutputStream
charsetName
- the name of a supported
charset
java.io.UnsupportedEncodingException
- If the named charset is not supportedCopyright © 1998-2012 Bela Ban / Red Hat. All Rights Reserved.