org.apache.commons.httpclient
Class ChunkedOutputStream
OutputStream
org.apache.commons.httpclient.ChunkedOutputStream
public class ChunkedOutputStream
extends OutputStream
Implements HTTP chunking support. Writes are buffered to an internal buffer (2048 default size).
Chunks are guaranteed to be at least as large as the buffer size (except for the last chunk).
- Mohammad Rezaei, Goldman, Sachs & Co.
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(bufferToAppend[] , int off, int len) - Writes the cache and bufferToAppend to the underlying stream
as one large chunk
|
void | write(b[] ) - Writes the array.
|
void | write(int b) - Write the specified byte to our output stream.
|
void | write(src[] , int off, int len)
|
protected void | writeClosingChunk()
|
ChunkedOutputStream
public ChunkedOutputStream(OutputStream stream)
throws IOException
Wraps a stream and chunks the output. The default buffer size of 2048 was chosen because
the chunk overhead is less than 0.5%
ChunkedOutputStream
public ChunkedOutputStream(OutputStream stream,
int bufferSize)
throws IOException
Wraps a stream and chunks the output.
stream
- to wrapbufferSize
- minimum chunk size (excluding last chunk)
close
public void close()
throws IOException
Finishes writing to the underlying stream, but does NOT close the underlying stream.
finish
public void finish()
throws IOException
Must be called to ensure the internal cache is flushed and the closing chunk is written.
flush
public void flush()
throws IOException
Flushes the underlying stream, but leaves the internal buffer alone.
flushCache
protected void flushCache()
throws IOException
Writes the cache out onto the underlying stream
flushCacheWithAppend
protected void flushCacheWithAppend(bufferToAppend[] ,
int off,
int len)
throws IOException
Writes the cache and bufferToAppend to the underlying stream
as one large chunk
write
public void write(b[] )
throws IOException
Writes the array. If the array does not fit within the buffer, it is
not split, but rather written out as one large chunk.
write
public void write(int b)
throws IOException
Write the specified byte to our output stream.
Note: Avoid this method as it will cause an inefficient single byte chunk.
Use write (byte[], int, int) instead.
b
- The byte to be written
write
public void write(src[] ,
int off,
int len)
throws IOException
writeClosingChunk
protected void writeClosingChunk()
throws IOException
Copyright (c) 1999-2005 - Apache Software Foundation