java.io.Closeable
, java.io.Flushable
, java.lang.AutoCloseable
public class ChunkedOutputStream
extends java.io.OutputStream
Constructor | Description |
---|---|
ChunkedOutputStream(java.io.OutputStream stream) |
Wraps a stream and chunks the output.
|
ChunkedOutputStream(java.io.OutputStream stream,
int bufferSize) |
Wraps a stream and chunks the output.
|
Modifier and Type | Method | 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 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
|
void |
write(byte[] b) |
Writes the array.
|
void |
write(byte[] src,
int off,
int len) |
|
void |
write(int b) |
Write the specified byte to our output stream.
|
protected void |
writeClosingChunk() |
public ChunkedOutputStream(java.io.OutputStream stream, int bufferSize) throws java.io.IOException
stream
- to wrapbufferSize
- minimum chunk size (excluding last chunk)java.io.IOException
public ChunkedOutputStream(java.io.OutputStream stream) throws java.io.IOException
stream
- java.io.IOException
protected void flushCache() throws java.io.IOException
java.io.IOException
protected void flushCacheWithAppend(byte[] bufferToAppend, int off, int len) throws java.io.IOException
bufferToAppend
- off
- len
- java.io.IOException
protected void writeClosingChunk() throws java.io.IOException
java.io.IOException
public void finish() throws java.io.IOException
java.io.IOException
public void write(int b) throws java.io.IOException
write
in class java.io.OutputStream
b
- The byte to be writtenjava.io.IOException
- if an input/output error occurspublic void write(byte[] b) throws java.io.IOException
write
in class java.io.OutputStream
b
- java.io.IOException
public void write(byte[] src, int off, int len) throws java.io.IOException
write
in class java.io.OutputStream
java.io.IOException
public void flush() throws java.io.IOException
flush
in interface java.io.Flushable
flush
in class java.io.OutputStream
java.io.IOException
public void close() throws java.io.IOException
close
in interface java.lang.AutoCloseable
close
in interface java.io.Closeable
close
in class java.io.OutputStream
java.io.IOException
Copyright (c) 1999-2005 - Apache Software Foundation