|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.OutputStream
com.sun.xml.ws.util.ByteArrayBuffer
public class ByteArrayBuffer
Read/write buffer that stores a sequence of bytes.
It works in a way similar to ByteArrayOutputStream
but
this class works better in the following ways:
newInputStream()
that creates a new InputStream
that won't cause buffer reallocation.
write(InputStream)
method that reads the entirety of the
given InputStream
without using a temporary buffer.
Field Summary | |
---|---|
protected byte[] |
buf
The buffer where data is stored. |
Constructor Summary | |
---|---|
ByteArrayBuffer()
Creates a new byte array output stream. |
|
ByteArrayBuffer(byte[] data)
|
|
ByteArrayBuffer(byte[] data,
int length)
|
|
ByteArrayBuffer(int size)
Creates a new byte array output stream, with a buffer capacity of the specified size, in bytes. |
Method Summary | |
---|---|
void |
close()
|
byte[] |
getRawData()
Gets the underlying buffer that this ByteArrayBuffer uses. |
InputStream |
newInputStream()
Creates a new InputStream that reads from this buffer. |
InputStream |
newInputStream(int start,
int length)
Creates a new InputStream that reads a part of this bfufer. |
void |
reset()
|
int |
size()
|
byte[] |
toByteArray()
Deprecated. this method causes a buffer reallocation. Use it only when you have to. |
String |
toString()
Decodes the contents of this buffer by the default encoding and returns it as a string. |
void |
write(byte[] b,
int off,
int len)
|
void |
write(InputStream in)
Reads all the data of the given InputStream and appends them
into this buffer. |
void |
write(int b)
|
void |
writeTo(OutputStream out)
|
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 |
Field Detail |
---|
protected byte[] buf
Constructor Detail |
---|
public ByteArrayBuffer()
public ByteArrayBuffer(int size)
size
- the initial size.
IllegalArgumentException
- if size is negative.public ByteArrayBuffer(byte[] data)
public ByteArrayBuffer(byte[] data, int length)
Method Detail |
---|
public final void write(InputStream in) throws IOException
InputStream
and appends them
into this buffer.
IOException
- if the read operation fails with an IOException
.public final void write(int b)
write
in class OutputStream
public final void write(byte[] b, int off, int len)
write
in class OutputStream
public final void writeTo(OutputStream out) throws IOException
IOException
public final void reset()
public final byte[] toByteArray()
Since this method needs to allocate a new byte[], this method will be costly.
public final int size()
public final byte[] getRawData()
ByteArrayBuffer
uses.
It's never small than its size()
.
Use with caution.
public void close() throws IOException
close
in interface Closeable
close
in class OutputStream
IOException
public final InputStream newInputStream()
InputStream
that reads from this buffer.
public final InputStream newInputStream(int start, int length)
InputStream
that reads a part of this bfufer.
public String toString()
Meant to aid debugging, but no more.
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |