Content-Length header.
Entities transferred using this stream can be maximum Long#MAX_VALUE
long.
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.
| Modifier and Type | Field and Description |
|---|---|
| private final SessionOutputBuffer | |
| private boolean | closed
True if the stream is closed. |
| private final long | contentLength
The maximum number of bytes that can be written the stream. |
| private final OutputStream | |
| private long | total
Total bytes written |
| Access | Constructor and Description |
|---|---|
| public | ContentLengthOutputStream(final SessionOutputBuffer
Session output buffer buffer, final OutputStream Output stream outputStream, final long The maximum number of bytes that can be written to
the stream. Subsequent write operations will be ignored. contentLength)Default constructor. |
| Modifier and Type | Method and Description |
|---|---|
| public void | close()
Overrides java. Implements java. |
| public void | flush()
Overrides java. Implements java. |
| public void | write(final byte[]
the data. b, final int the start offset in the data. off, final int the number of bytes to write. len)Overrides java. len bytes from the specified byte array
starting at offset off to this output stream.
|
| public void | write(final byte[]
the data. b)Overrides java. b.length bytes from the specified byte array
to this output stream.
|
| public void | write(final int
the b)byte.Implements abstract java. |
| buffer | back to summary |
|---|---|
| private final SessionOutputBuffer buffer | |
| closed | back to summary |
|---|---|
| private boolean closed True if the stream is closed. | |
| contentLength | back to summary |
|---|---|
| private final long contentLength The maximum number of bytes that can be written the stream. Subsequent write operations will be ignored. | |
| outputStream | back to summary |
|---|---|
| private final OutputStream outputStream | |
| total | back to summary |
|---|---|
| private long total Total bytes written | |
| ContentLengthOutputStream | back to summary |
|---|---|
| public ContentLengthOutputStream(final SessionOutputBuffer buffer, final OutputStream outputStream, final long contentLength) Default constructor.
| |
| close | back to summary |
|---|---|
| public void close() throws IOException Overrides java. Implements java. Finishes writing to the underlying stream, but does NOT close the underlying stream.
| |
| flush | back to summary |
|---|---|
| public void flush() throws IOException Overrides java. Implements java. Doc from java. Flushes this output stream and forces any buffered output bytes
to be written out. The general contract of If the intended destination of this stream is an abstraction provided by the underlying operating system, for example a file, then flushing the stream guarantees only that bytes previously written to the stream are passed to the operating system for writing; it does not guarantee that they are actually written to a physical device such as a disk drive.
| |
| write | back to summary |
|---|---|
| public void write(final byte[] b, final int off, final int len) throws IOException Overrides java. Doc from java. Writes
If
If
| |
| write | back to summary |
|---|---|
| public void write(final byte[] b) throws IOException Overrides java. Doc from java. Writes
| |
| write | back to summary |
|---|---|
| public void write(final int b) throws IOException Implements abstract java. Doc from java. Writes the specified byte to this output stream. The general
contract for
| |