|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.OutputStream
java.io.ByteArrayOutputStream
com.tffenterprises.io.ByteArrayOutputStream
public class ByteArrayOutputStream
com.tffenterprises.io.ByteArrayOutputStream
is intended to be
a drop-in replacement for java.io.ByteArrayOutputStream
.
It functions in exactly the same way as its superclass, with the
advantage that the method
write(byte[] b)
throws no exceptions (except in the writeTo(OutputStream out)
method, in which the exception potentially comes from the parameter).
This class implements an output stream in which the data is written into a byte array. The buffer automatically grows as data is written to it. The data can be retrieved using toByteArray() and toString().
Field Summary | |
---|---|
private byte[] |
buf
private buffer to assist with the more complicated DataOutput methods. |
Fields inherited from class java.io.ByteArrayOutputStream |
---|
count |
Constructor Summary | |
---|---|
ByteArrayOutputStream()
Creates a ByteArrayOutputStream . |
|
ByteArrayOutputStream(int size)
Creates a new ByteArrayOutputStream , with a buffer capacity
of the specified size, in bytes. |
Method Summary | |
---|---|
void |
flush()
Flushes this output stream and forces any buffered output bytes to be written out. |
void |
write(byte[] b)
Writes b.length bytes from the specified byte array. |
void |
writeBoolean(boolean bool)
Writes a boolean value to this output stream. |
void |
writeByte(int b)
Writes a byte value to this output stream. |
void |
writeBytes(java.lang.String s)
Writes the low-order-byte values of the given String parameter's chars, effectively writing the characters as ISO-8859-1 encoding. |
void |
writeChar(int c)
Writes a char value to this output stream. |
void |
writeChars(java.lang.String s)
Writes a String as a sequence of chars (2-byte values). |
void |
writeDouble(double d)
Writes a double value to this output stream. |
void |
writeFloat(float f)
Writes a float value to this output stream. |
void |
writeInt(int i)
Writes an int value to this output stream. |
void |
writeLong(long l)
Writes a long value to this output stream. |
void |
writeShort(int s)
Writes a short value to this output stream. |
void |
writeUTF(java.lang.String s)
Writes a String encoded as UTF-8. |
long |
written()
Returns the number of bytes that have been written to the output buffer. |
Methods inherited from class java.io.ByteArrayOutputStream |
---|
close, reset, size, toByteArray, toString, toString, toString, write, write, writeTo |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.io.DataOutput |
---|
write, write |
Field Detail |
---|
private byte[] buf
Constructor Detail |
---|
public ByteArrayOutputStream()
ByteArrayOutputStream
.
The buffer capacity is initially 32 bytes, but will grow as necessary.
public ByteArrayOutputStream(int size) throws java.lang.IllegalArgumentException
ByteArrayOutputStream
, with a buffer capacity
of the specified size, in bytes.
size
- the initial size.
java.lang.IllegalArgumentException
- if size
is negative.Method Detail |
---|
public void write(byte[] b)
b.length
bytes from the specified byte array.
This is equivalent to using write(b, 0, b.length)
.
write
in interface java.io.DataOutput
write
in class java.io.OutputStream
b
- the datapublic void flush()
The general contract of flush()
is that calling it is an indication that,
if any bytes previously written have been buffered by the
output stream object, such bytes should immediately be
written to their intended destination.
The flush()
method of
ByteArrayOutputStream
does nothing.
flush
in interface java.io.Flushable
flush
in class java.io.OutputStream
public long written()
written
in interface AccountingOutput
public void writeBoolean(boolean bool)
writeBoolean
in interface java.io.DataOutput
bool
- the boolean value to be written out.public void writeByte(int b)
writeByte
in interface java.io.DataOutput
b
- the byte value to be written out.public void writeShort(int s)
writeShort
in interface java.io.DataOutput
s
- the short value to be written out.public void writeChar(int c)
writeChar
in interface java.io.DataOutput
c
- the char value to be written out.public void writeInt(int i)
writeInt
in interface java.io.DataOutput
i
- the int value to be written out.public void writeLong(long l)
writeLong
in interface java.io.DataOutput
l
- the long value to be written out.public void writeFloat(float f)
writeFloat
in interface java.io.DataOutput
f
- the float value to be written out.public void writeDouble(double d)
writeDouble
in interface java.io.DataOutput
d
- the double value to be written out.public void writeBytes(java.lang.String s)
writeBytes
in interface java.io.DataOutput
s
- the String to be written out as ISO-8859-1.public void writeChars(java.lang.String s)
writeChars
in interface java.io.DataOutput
s
- the String to be written out to the stream.public void writeUTF(java.lang.String s) throws java.io.UTFDataFormatException
writeUTF
in interface java.io.DataOutput
s
- the String to be written out to the stream as UTF-8.
java.io.UTFDataFormatException
- if the required number of output bytes
exceeds 65535.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |