|
jamod at SF | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.io.OutputStream
net.wimpi.modbus.io.FastByteArrayOutputStream
This class is a replacement implementation for ByteArrayOutputStream that does not synchronize every byte written.
| Field Summary | |
protected byte[] |
buf
Output buffer byte[]. |
protected int |
bumpLen
Increment of the output buffer size on overflow. |
protected int |
count
Number of bytes in the output buffer. |
static int |
DEFAULT_BUMP_SIZE
Defines the default increment of the output buffer size (100 bytes). |
static int |
DEFAULT_INIT_SIZE
Defines the default oputput buffer size (100 bytes). |
| Constructor Summary | |
FastByteArrayOutputStream()
Creates an output stream with default sizes. |
|
FastByteArrayOutputStream(byte[] buffer)
Creates an output stream with a given initial buffer and a default bump size. |
|
FastByteArrayOutputStream(byte[] buffer,
int bumpSize)
Creates an output stream with a given initial buffer and a given bump size. |
|
FastByteArrayOutputStream(int initialSize)
Creates an output stream with a default bump size and a given initial size. |
|
FastByteArrayOutputStream(int initialSize,
int bumpSize)
Creates an output stream with a given bump size and initial size. |
|
| Method Summary | |
void |
addSize(int sizeAdded)
Skip the given number of bytes in the buffer. |
byte[] |
getBufferBytes()
Returns the buffer owned by this object. |
int |
getBufferLength()
Returns the length used in the internal buffer, that is, the offset at which data will be written next. |
int |
getBufferOffset()
Returns the offset of the internal buffer. |
void |
makeSpace(int sizeNeeded)
Ensure that at least the given number of bytes are available in the internal buffer. |
void |
reset()
Resets this FastByteArrayOutputStream. |
int |
size()
Returns the number of bytes written to this FastByteArrayOutputStream. |
byte[] |
toByteArray()
Returns the written bytes in a newly allocated byte[] of length getSize(). |
void |
toByteArray(byte[] toBuf,
int offset)
Copy the buffered data to the given array. |
java.lang.String |
toString()
|
java.lang.String |
toString(java.lang.String encoding)
Returns the content of this FastByteArrayOutputStream as String. |
void |
write(byte[] fromBuf)
|
void |
write(byte[] fromBuf,
int offset,
int length)
|
void |
write(int b)
|
void |
writeTo(java.io.OutputStream out)
Writes the content of this FastByteArrayOutputStream to the given output stream. |
| Methods inherited from class java.io.OutputStream |
close, flush |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static final int DEFAULT_INIT_SIZE
public static final int DEFAULT_BUMP_SIZE
protected int count
protected int bumpLen
protected byte[] buf
| Constructor Detail |
public FastByteArrayOutputStream()
public FastByteArrayOutputStream(int initialSize)
initialSize - the initial size of the buffer.
public FastByteArrayOutputStream(int initialSize,
int bumpSize)
initialSize - the initial size of the buffer.bumpSize - the amount to increment the buffer.public FastByteArrayOutputStream(byte[] buffer)
buffer - the initial buffer; will be owned by this object.
public FastByteArrayOutputStream(byte[] buffer,
int bumpSize)
buffer - the initial buffer; will be owned by this object.bumpSize - the amount to increment the buffer.| Method Detail |
public int size()
public void reset()
public void write(int b)
throws java.io.IOException
java.io.IOException
public void write(byte[] fromBuf)
throws java.io.IOException
java.io.IOException
public void write(byte[] fromBuf,
int offset,
int length)
throws java.io.IOException
java.io.IOException
public void writeTo(java.io.OutputStream out)
throws java.io.IOException
out - the output stream to be written to.
java.io.IOException - if an I/O error occurs.public java.lang.String toString()
public java.lang.String toString(java.lang.String encoding)
throws java.io.UnsupportedEncodingException
encoding - the encoding to be used for conversion.
java.io.UnsupportedEncodingException - if the given encoding is not supported.public byte[] toByteArray()
public void toByteArray(byte[] toBuf,
int offset)
toBuf - the buffer to hold a copy of the data.offset - the offset at which to start copying.public byte[] getBufferBytes()
public int getBufferOffset()
public int getBufferLength()
public void makeSpace(int sizeNeeded)
sizeNeeded - the number of bytes desired.public void addSize(int sizeAdded)
sizeAdded - number of bytes to skip.
|
jamod at SF | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||