|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object jcontrol.io.OutputStream jcontrol.io.ByteArrayOutputStream
public class ByteArrayOutputStream
The ByteArrayOutputStream
is a simple OutputStream
for writing
data to a byte array. The byte array can either be of fixed size or expandable.
Internally a write pointer is used, which is automatically increased on write accesses.
It can be reset through the reset()
method.
Field Summary | |
---|---|
protected byte[] |
m_array
Underlying byte array. |
protected int |
m_maxSize
Maximum byte array size. |
protected int |
m_writePos
Current writing prosition. |
Constructor Summary | |
---|---|
ByteArrayOutputStream()
Creates a ByteArrayOutputStream with dynamic size. |
|
ByteArrayOutputStream(byte[] array)
Creates a ByteArrayOutputStream for writing to the specified array. |
|
ByteArrayOutputStream(int size)
Creates a ByteArrayOutputStream with a fixed size. |
Method Summary | |
---|---|
void |
close()
Has no effect on a ByteArrayOutputStream . |
void |
flush()
Has no effect on a ByteArrayOutputStream . |
byte[] |
getBytes()
Returns the underlying byte array. |
void |
reset()
Resets the write pointer. |
void |
write(byte[] b,
int start,
int length)
Writes a part of an array to the OutputStream. |
void |
write(int b)
Writes a single byte to the OutputStream. |
void |
writeOut(OutputStream out)
Writes the content of the underlying byte array to another OutputStream . |
Methods inherited from class jcontrol.io.OutputStream |
---|
write |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, notifyAll, toString, wait |
Field Detail |
---|
protected byte[] m_array
protected int m_maxSize
protected int m_writePos
Constructor Detail |
---|
public ByteArrayOutputStream(byte[] array)
array
- byte array to write topublic ByteArrayOutputStream(int size)
size
- desired array sizepublic ByteArrayOutputStream()
ByteArrayOutputStream
with dynamic size. The size of the underlying
byte array is increased when needed.
Method Detail |
---|
public void close()
ByteArrayOutputStream
.
close
in class OutputStream
public void flush()
ByteArrayOutputStream
.
flush
in class OutputStream
public void write(int b)
OutputStream
write
in class OutputStream
b
- byte to writepublic void write(byte[] b, int start, int length)
OutputStream
write
in class OutputStream
b
- array containing the data to sendstart
- index of the first byte to send in the arraylength
- number of bytes to sendpublic void reset()
public byte[] getBytes()
public void writeOut(OutputStream out) throws IOException
OutputStream
.
out
- OutputStream
IOException
- occurs in case of I/O errors or when OutputStream out
is closed
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |