Class Overview
Implements chunked transfer coding.
See RFC 2616,
section 3.6.1.
Writes are buffered to an internal buffer (2048 default size).
Summary
Public Methods |
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[] src, int off, int len)
Writes count bytes from the byte array buffer starting at
position offset to this stream.
|
void
|
write(byte[] b)
Writes the array.
|
void
|
write(int b)
Writes a single byte to this stream.
|
Protected Methods |
void
|
flushCache()
Writes the cache out onto the underlying stream
|
void
|
flushCacheWithAppend(byte[] bufferToAppend, int off, int len)
Writes the cache and bufferToAppend to the underlying stream
as one large chunk
|
void
|
writeClosingChunk()
|
[Expand]
Inherited Methods |
From class
java.io.OutputStream
void
|
close()
Closes this stream.
|
void
|
flush()
Flushes this stream.
|
void
|
write(byte[] buffer, int offset, int count)
Writes count bytes from the byte array buffer starting at
position offset to this stream.
|
void
|
write(byte[] buffer)
Writes the entire contents of the byte array buffer to this
stream.
|
abstract
void
|
write(int oneByte)
Writes a single byte to this stream.
|
|
From class
java.lang.Object
Object
|
clone()
Creates and returns a copy of this Object .
|
boolean
|
equals(Object o)
Compares this instance with the specified object and indicates if they
are equal.
|
void
|
finalize()
Called before the object's memory is reclaimed by the VM.
|
final
Class<?>
|
getClass()
Returns the unique instance of Class that represents this
object's class.
|
int
|
hashCode()
Returns an integer hash code for this object.
|
final
void
|
notify()
Causes a thread which is waiting on this object's monitor (by means of
calling one of the wait() methods) to be woken up.
|
final
void
|
notifyAll()
Causes all threads which are waiting on this object's monitor (by means
of calling one of the wait() methods) to be woken up.
|
String
|
toString()
Returns a string containing a concise, human-readable description of this
object.
|
final
void
|
wait()
Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object.
|
final
void
|
wait(long millis, int nanos)
Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object or until the
specified timeout expires.
|
final
void
|
wait(long millis)
Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object or until the
specified timeout expires.
|
|
From interface
java.io.Closeable
abstract
void
|
close()
Closes the object and release any system resources it holds.
|
|
From interface
java.io.Flushable
abstract
void
|
flush()
Flushes the object by writing out any buffered data to the underlying
output.
|
|
Public Constructors
public
ChunkedOutputStream
(SessionOutputBuffer out, int bufferSize)
Wraps a session output buffer and chunks the output.
Parameters
out
| the session output buffer to wrap |
bufferSize
| minimum chunk size (excluding last chunk) |
Wraps a session output buffer and chunks the output. The default buffer
size of 2048 was chosen because the chunk overhead is less than 0.5%
Parameters
out
| the output buffer to wrap |
Public Methods
public
void
close
()
Finishes writing to the underlying stream, but does NOT close the underlying stream.
public
void
finish
()
Must be called to ensure the internal cache is flushed and the closing chunk is written.
public
void
flush
()
Flushes the content buffer and the underlying stream.
public
void
write
(byte[] src, int off, int len)
Writes count
bytes from the byte array buffer
starting at
position offset
to this stream.
Parameters
src
| the buffer to be written. |
off
| the start position in buffer from where to get bytes. |
len
| the number of bytes from buffer to write to this
stream. |
public
void
write
(byte[] b)
Writes the array. If the array does not fit within the buffer, it is
not split, but rather written out as one large chunk.
Parameters
b
| the buffer to be written. |
public
void
write
(int b)
Writes a single byte to this stream. Only the least significant byte of
the integer oneByte
is written to the stream.
Parameters
b
| the byte to be written. |
Protected Methods
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
protected
void
writeClosingChunk
()