public final class HeaderOutputStream
extends java.io.ByteArrayOutputStream
HeaderOutputStream - Reads until two subsequent CR?LF sequences are detected| Constructor and Description |
|---|
HeaderOutputStream()
Creates a new byte array output stream.
|
HeaderOutputStream(int size)
Creates a new byte array output stream, with a buffer capacity of the specified size, in bytes.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closing a byte array output stream has no effect.
|
void |
reset()
Resets the
count field of this byte array output stream to zero, so that all currently accumulated output in the output
stream is discarded. |
int |
size()
Returns the current size of the buffer.
|
byte[] |
toByteArray()
Creates a newly allocated byte array.
|
byte[] |
toByteArray(int off,
int size)
Creates a newly allocated byte array.
|
java.lang.String |
toString()
Converts the buffer's contents into a string, translating bytes into characters according to the platform's default character
encoding.
|
java.lang.String |
toString(int hibyte)
Deprecated.
This method does not properly convert bytes into characters. As of JDK 1.1, the preferred way to do this is via the
toString(String enc) method, which takes an encoding-name argument, or the toString() method,
which uses the platform's default character encoding. |
java.lang.String |
toString(java.lang.String enc)
Converts the buffer's contents into a string, translating bytes into characters according to the specified character encoding.
|
void |
write(byte[] b,
int off,
int len)
Writes
len bytes from the specified byte array starting at offset off to this byte array output stream. |
void |
write(int b)
Writes the specified byte to this byte array output stream.
|
void |
writeTo(java.io.OutputStream out)
Writes the complete contents of this byte array output stream to the specified output stream argument, as if by calling the output
stream's write method using
out.write(buf, 0, count). |
public HeaderOutputStream()
public HeaderOutputStream(int size)
size - The initial size.java.lang.IllegalArgumentException - If size is negative.public void write(int b)
write in class java.io.ByteArrayOutputStreamb - The byte to be written.public void write(byte[] b,
int off,
int len)
len bytes from the specified byte array starting at offset off to this byte array output stream.write in class java.io.ByteArrayOutputStreamb - The data.off - The start offset in the data.len - The number of bytes to write.public void writeTo(java.io.OutputStream out)
throws java.io.IOException
out.write(buf, 0, count).writeTo in class java.io.ByteArrayOutputStreamout - The output stream to which to write the data.java.io.IOException - If an I/O error occurs.public void reset()
count field of this byte array output stream to zero, so that all currently accumulated output in the output
stream is discarded. The output stream can be used again, reusing the already allocated buffer space.reset in class java.io.ByteArrayOutputStreampublic byte[] toByteArray()
toByteArray in class java.io.ByteArrayOutputStreampublic byte[] toByteArray(int off,
int size)
size and the valid contents starting from specified offset
off are going to be copied into it.off - The offset in valid contentssize - The demanded sizepublic int size()
size in class java.io.ByteArrayOutputStreamcount field, which is the number of valid bytes in this output stream.public java.lang.String toString()
toString in class java.io.ByteArrayOutputStreampublic java.lang.String toString(java.lang.String enc)
throws java.io.UnsupportedEncodingException
toString in class java.io.ByteArrayOutputStreamenc - The character-encoding name.java.io.UnsupportedEncodingException - If the named encoding is not supported.@Deprecated public java.lang.String toString(int hibyte)
toString(String enc) method, which takes an encoding-name argument, or the toString() method,
which uses the platform's default character encoding.c == (char) (((hibyte & 0xff) << 8) | (b & 0xff))
toString in class java.io.ByteArrayOutputStreamhibyte - The high byte of each resulting Unicode character.public void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in class java.io.ByteArrayOutputStreamjava.io.IOException