|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.io.OutputStream java.io.ByteArrayOutputStream org.jgroups.util.ExposedByteArrayOutputStream
public class ExposedByteArrayOutputStream
Extends ByteArrayOutputStream, but exposes the internal buffer. This way we don't need to call toByteArray() which copies the internal buffer
Field Summary |
---|
Fields inherited from class java.io.ByteArrayOutputStream |
---|
buf, count |
Constructor Summary | |
---|---|
ExposedByteArrayOutputStream()
|
|
ExposedByteArrayOutputStream(int size)
|
Method Summary | |
---|---|
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) . |
Methods inherited from class java.io.ByteArrayOutputStream |
---|
close, toString |
Methods inherited from class java.io.OutputStream |
---|
flush, write |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public ExposedByteArrayOutputStream()
public ExposedByteArrayOutputStream(int size)
Method Detail |
---|
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
- Returns:
- String decoded from the buffer's contents.
- Throws:
java.io.UnsupportedEncodingException
- If the named charset is not supported- Since:
- JDK1.1
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |