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(SessionOutputBuffer buffer,
OutputStream outputStream,
byte[] chunkCache,
Supplier<List<? extends Header>> trailerSupplier)
Default constructor.
|
ChunkedOutputStream(SessionOutputBuffer buffer,
OutputStream outputStream,
int chunkSizeHint)
Constructor with no trailers.
|
ChunkedOutputStream(SessionOutputBuffer buffer,
OutputStream outputStream,
int chunkSizeHint,
Supplier<List<? extends Header>> trailerSupplier)
Constructor taking an integer chunk size hint.
|
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.
|
void |
write(byte[] b)
Writes the array.
|
void |
write(byte[] src,
int off,
int len)
Writes the array.
|
void |
write(int b) |
public ChunkedOutputStream(SessionOutputBuffer buffer, OutputStream outputStream, byte[] chunkCache, Supplier<List<? extends Header>> trailerSupplier)
buffer
- Session output bufferoutputStream
- Output streamchunkCache
- Buffer used to aggregate smaller writes into chunks.trailerSupplier
- Trailer supplier. May be null
public ChunkedOutputStream(SessionOutputBuffer buffer, OutputStream outputStream, int chunkSizeHint, Supplier<List<? extends Header>> trailerSupplier)
buffer
- Session output bufferoutputStream
- Output streamchunkSizeHint
- minimal chunk size hinttrailerSupplier
- Trailer supplier. May be null
public ChunkedOutputStream(SessionOutputBuffer buffer, OutputStream outputStream, int chunkSizeHint)
buffer
- Session output bufferoutputStream
- Output streamchunkSizeHint
- minimal chunk size hintpublic 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–2021 The Apache Software Foundation. All rights reserved.