Android APIs
Added in API level 1
Deprecated since API level 22
public class

ContentLengthOutputStream

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

This class was deprecated in API level 22.
Please use openConnection() instead. Please visit this webpage for further details.

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.

Throws
IOException

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

public void write (byte[] b)

Added in API level 1

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

Throws
IOException

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