public class

ContentLengthOutputStream

extends OutputStream
java.lang.Object
   ↳ java.io.OutputStream
     ↳ org.apache.http.impl.io.ContentLengthOutputStream

Class Overview

A stream wrapper that closes itself after a defined number of bytes.

Summary

Public Constructors
ContentLengthOutputStream(SessionOutputBuffer out, long contentLength)
Creates a new length limited stream
Public Methods
void close()

Does not close the underlying socket output.

void flush()
Flushes this stream.
void write(byte[] b, 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 entire contents of the byte array buffer to this stream.
void write(int b)
Writes a single byte to this stream.
[Expand]
Inherited Methods
From class java.io.OutputStream
From class java.lang.Object
From interface java.io.Closeable
From interface java.io.Flushable

Public Constructors

public ContentLengthOutputStream (SessionOutputBuffer out, long contentLength)

Since: API Level 1

Creates a new length limited stream

Parameters
out The data transmitter to wrap
contentLength The maximum number of bytes that can be written to the stream. Subsequent write operations will be ignored.

Public Methods

public void close ()

Since: API Level 1

Does not close the underlying socket output.

Throws
IOException If an I/O problem occurs.

public void flush ()

Since: API Level 1

Flushes this stream. Implementations of this method should ensure that any buffered data is written out. This implementation does nothing.

Throws
IOException

public void write (byte[] b, int off, int len)

Since: API Level 1

Writes count bytes from the byte array buffer starting at position offset to this stream.

Parameters
b 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.
Throws
IOException

public void write (byte[] b)

Since: API Level 1

Writes the entire contents of the byte array buffer to this stream.

Parameters
b the buffer to be written.
Throws
IOException

public void write (int b)

Since: API Level 1

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.
Throws
IOException