public class ChunkedOutputStream
extends java.io.OutputStream
Modifier and Type | Field and Description |
---|---|
protected java.io.OutputStream |
_rawOS |
protected java.lang.String |
closedMsg |
protected boolean |
isOpen |
Constructor and Description |
---|
ChunkedOutputStream(java.io.OutputStream stream)
Wraps a stream and chunks the output.
|
ChunkedOutputStream(java.io.OutputStream stream,
int minChunkSize)
Wraps a stream and chunks the output.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Finishes writing to the underlying stream, but does NOT close the
underlying stream.
|
void |
finish()
Completes a chunked transmission.
|
void |
flush()
Flushes the underlying stream, but leaves the internal buffer alone.
|
protected void |
flushCache()
Writes the cache out onto the underlying stream.
|
protected void |
flushCacheWithAppend(byte[] bufferToAppend,
int off,
int len)
Writes the cache and bufferToAppend to the underlying stream as one
large chunk.
|
int |
getChunkType() |
static void |
main(java.lang.String[] args) |
void |
setChunkType(int type) |
void |
setChunkTypeToDATA() |
void |
setChunkTypeToEXTENSION() |
java.lang.String |
toString() |
void |
write(byte[] b)
Writes the array.
|
void |
write(byte[] b,
int off,
int len) |
void |
write(int b)
Write the specified byte to our output stream.
|
protected java.io.OutputStream _rawOS
protected boolean isOpen
protected java.lang.String closedMsg
public ChunkedOutputStream(java.io.OutputStream stream)
stream
- to wrappublic ChunkedOutputStream(java.io.OutputStream stream, int minChunkSize) throws java.lang.Exception
stream
- to wrapminChunkSize
- minimum chunk size (excluding last chunk)java.lang.Exception
- if the minimum chunk size is larger than 65535 (0xFFFF)
bytes.public void setChunkType(int type) throws java.lang.Exception
java.lang.Exception
public void setChunkTypeToDATA()
public void setChunkTypeToEXTENSION()
public int getChunkType()
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in class java.io.OutputStream
java.io.IOException
- When the wrapped OutputStream encounters a problem.public void finish() throws java.io.IOException
java.io.IOException
- When the wrapped OutputStream encounters a problem.public void flush() throws java.io.IOException
flush
in interface java.io.Flushable
flush
in class java.io.OutputStream
java.io.IOException
- When the wrapped OutputStream encounters a problem.protected void flushCache() throws java.io.IOException
java.io.IOException
- When the wrapped OutputStream encounters a problem.protected void flushCacheWithAppend(byte[] bufferToAppend, int off, int len) throws java.io.IOException
bufferToAppend
- The buffer to append to the cache.off
- Offset within the buffer.len
- Number of bytes to write from the bufferjava.io.IOException
- When the wrapped OutputStream encounters a problem.public void write(byte[] b) throws java.io.IOException
write
in class java.io.OutputStream
b
- The buffer to write.java.io.IOException
- When the wrapped OutputStream encounters a problem.public void write(byte[] b, int off, int len) throws java.io.IOException
write
in class java.io.OutputStream
b
- The buffer to write.off
- Offset within the buffer.len
- Number of bytes to write from the bufferjava.io.IOException
- When the wrapped OutputStream encounters a problem.public void write(int b) throws java.io.IOException
write
in class java.io.OutputStream
b
- The byte to be written.java.io.IOException
- When the wrapped OutputStream encounters a problem.public static void main(java.lang.String[] args) throws java.lang.Exception
java.lang.Exception
public java.lang.String toString()
toString
in class java.lang.Object