Please note that the contents of this offline web site may be out of date. To access the most recent documentation visit the online version .
Note that links that point to online resources are green in color and will open in a new window.
We would love it if you could give us feedback about this material by filling this form (You have to be online to fill it)
Android APIs
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)
Equivalent to write(buffer, 0, buffer.length) .
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
From interface java.lang.AutoCloseable

Public Constructors

public ContentLengthOutputStream ( SessionOutputBuffer out, long contentLength)

Added in 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 ()

Added in API level 1

Does not close the underlying socket output.

Throws
IOException If an I/O problem occurs.

public void flush ()

Added in API level 1

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

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

Added in 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.

public void write (byte[] b)

Added in API level 1

Equivalent to write(buffer, 0, buffer.length) .

public void write (int b)

Added in 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.