|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.OutputStream
com.devexperts.io.BufferedOutput
com.devexperts.io.ByteArrayOutput
public class ByteArrayOutput
An implementation of BufferedOutput
using single byte array buffer.
Field Summary |
---|
Fields inherited from class com.devexperts.io.BufferedOutput |
---|
buffer, EMPTY_BYTE_ARRAY, limit, position |
Constructor Summary | |
---|---|
ByteArrayOutput()
Creates a new byte array output without pre-allocated buffer. |
|
ByteArrayOutput(int size)
Creates a new byte array output with specified buffer capacity. |
Method Summary | |
---|---|
void |
clear()
Clears this buffer. |
void |
ensureCapacity(int requiredCapacity)
Ensures that the byte array used for buffering has at least the specified capacity. |
byte[] |
getBuffer()
Returns byte array used for buffering. |
int |
getLimit()
Returns limit. |
int |
getPosition()
Returns position. |
protected void |
needSpace()
This method is invoked when output methods need more space to write data. |
void |
setBuffer(byte[] newBuffer)
Sets specified byte array to be used for buffering. |
void |
setLimit(int newLimit)
Sets limit as specified. |
void |
setPosition(int newPosition)
Sets position as specified. |
byte[] |
toByteArray()
Returns a full copy of byte array buffer from zero to the position. |
String |
toString()
Converts the buffer's content from zero to the position into a string, translating bytes into characters according to the platform's default character encoding. |
Methods inherited from class com.devexperts.io.BufferedOutput |
---|
write, write, write, writeBoolean, writeByte, writeByteArray, writeBytes, writeChar, writeChars, writeCompactInt, writeCompactLong, writeDouble, writeFloat, writeInt, writeLong, writeObject, writeShort, writeUTF, writeUTFChar, writeUTFString |
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 |
Methods inherited from interface java.io.ObjectOutput |
---|
close, flush |
Constructor Detail |
---|
public ByteArrayOutput()
public ByteArrayOutput(int size)
size
- the initial buffer size
IllegalArgumentException
- if size is negativeMethod Detail |
---|
protected void needSpace() throws IOException
BufferedOutput
(position < limit)
is true or throw an exception. This method may block if needed.
This method is allowed to update buffer, position and limit fields as needed.
needSpace
in class BufferedOutput
IOException
- if an I/O error occurspublic byte[] getBuffer()
public void setBuffer(byte[] newBuffer)
public int getPosition()
public void setPosition(int newPosition)
IllegalArgumentException
- if the new position is negative or is larger than the limitpublic int getLimit()
public void setLimit(int newLimit)
IllegalArgumentException
- if the new limit is negative or is larger than the capacitypublic void clear()
public void ensureCapacity(int requiredCapacity)
public byte[] toByteArray()
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |