public class ChunkedOutputStream extends OutputStream
Note that this class NEVER closes the underlying stream, even when close gets called. Instead, the stream will be marked as closed and no further output will be permitted.
Constructor and Description |
---|
ChunkedOutputStream(int bufferSize,
SessionOutputBuffer out)
Wraps a session output buffer and chunk-encodes the output.
|
ChunkedOutputStream(SessionOutputBuffer out)
Deprecated.
|
ChunkedOutputStream(SessionOutputBuffer out,
int bufferSize)
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Finishes writing to the underlying stream, but does NOT close the underlying stream.
|
void |
finish()
Must be called to ensure the internal cache is flushed and the closing
chunk is written.
|
void |
flush()
Flushes the content buffer and the underlying stream.
|
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
|
void |
write(byte[] b)
Writes the array.
|
void |
write(byte[] src,
int off,
int len)
Writes the array.
|
void |
write(int b) |
protected void |
writeClosingChunk() |
@Deprecated public ChunkedOutputStream(SessionOutputBuffer out, int bufferSize) throws IOException
ChunkedOutputStream(int, SessionOutputBuffer)
out
- The session output bufferbufferSize
- The minimum chunk size (excluding last chunk)IOException
- not thrown@Deprecated public ChunkedOutputStream(SessionOutputBuffer out) throws IOException
ChunkedOutputStream(int, SessionOutputBuffer)
out
- the output buffer to wrapIOException
- not thrownpublic ChunkedOutputStream(int bufferSize, SessionOutputBuffer out)
bufferSize
- The minimum chunk size (excluding last chunk)out
- The session output bufferprotected void flushCache() throws IOException
IOException
protected void flushCacheWithAppend(byte[] bufferToAppend, int off, int len) throws IOException
IOException
protected void writeClosingChunk() throws IOException
IOException
public void finish() throws IOException
IOException
- in case of an I/O errorpublic void write(int b) throws IOException
write
in class OutputStream
IOException
public void write(byte[] b) throws IOException
write
in class OutputStream
IOException
public void write(byte[] src, int off, int len) throws IOException
write
in class OutputStream
IOException
public void flush() throws IOException
flush
in interface Flushable
flush
in class OutputStream
IOException
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class OutputStream
IOException
Copyright © 2005–2022 The Apache Software Foundation. All rights reserved.