Skip to content

Most visited

Recently visited

navigation
Added in API level 9

DeflaterInputStream

public class DeflaterInputStream
extends FilterInputStream

java.lang.Object
   ↳ java.io.InputStream
     ↳ java.io.FilterInputStream
       ↳ java.util.zip.DeflaterInputStream


An InputStream filter to compress data. Callers read compressed data in the "deflate" format from the uncompressed underlying stream.

Summary

Fields

protected final byte[] buf

protected final Deflater def

Inherited fields

From class java.io.FilterInputStream

Public constructors

DeflaterInputStream(InputStream in)

Constructs a DeflaterInputStream with a new Deflater and an implementation-defined default internal buffer size.

DeflaterInputStream(InputStream in, Deflater deflater)

Constructs a DeflaterInputStream with the given Deflater and an implementation-defined default internal buffer size.

DeflaterInputStream(InputStream in, Deflater deflater, int bufferSize)

Constructs a DeflaterInputStream with the given Deflater and given internal buffer size.

Public methods

int available()

Returns 0 when when this stream has exhausted its input; and 1 otherwise.

void close()

Closes the underlying input stream and discards any remaining uncompressed data.

void mark(int limit)

This operation is not supported and does nothing.

boolean markSupported()

Returns false because DeflaterInputStream does not support mark/reset.

int read()

Reads a byte from the compressed input stream.

int read(byte[] buffer, int byteOffset, int byteCount)

Reads up to byteCount bytes of compressed data into a byte buffer.

void reset()

This operation is not supported and throws IOException.

long skip(long byteCount)

Skips byteCount bytes in this stream.

Note: if n > Integer.MAX_VALUE, this stream will only attempt to skip Integer.MAX_VALUE bytes.

Inherited methods

From class java.io.FilterInputStream
From class java.io.InputStream
From class java.lang.Object
From interface java.io.Closeable
From interface java.lang.AutoCloseable

Fields

buf

Added in API level 9
byte[] buf

def

Added in API level 9
Deflater def

Public constructors

DeflaterInputStream

Added in API level 9
DeflaterInputStream (InputStream in)

Constructs a DeflaterInputStream with a new Deflater and an implementation-defined default internal buffer size. in is a source of uncompressed data, and this stream will be a source of compressed data.

Parameters
in InputStream: the source InputStream

DeflaterInputStream

Added in API level 9
DeflaterInputStream (InputStream in, 
                Deflater deflater)

Constructs a DeflaterInputStream with the given Deflater and an implementation-defined default internal buffer size. in is a source of uncompressed data, and this stream will be a source of compressed data.

Parameters
in InputStream: the source InputStream
deflater Deflater: the Deflater to be used for compression

DeflaterInputStream

Added in API level 9
DeflaterInputStream (InputStream in, 
                Deflater deflater, 
                int bufferSize)

Constructs a DeflaterInputStream with the given Deflater and given internal buffer size. in is a source of uncompressed data, and this stream will be a source of compressed data.

Parameters
in InputStream: the source InputStream
deflater Deflater: the Deflater to be used for compression
bufferSize int: the length in bytes of the internal buffer

Public methods

available

Added in API level 9
int available ()

Returns 0 when when this stream has exhausted its input; and 1 otherwise. A result of 1 does not guarantee that further bytes can be returned, with or without blocking.

Although consistent with the RI, this behavior is inconsistent with available(), and violates the Liskov Substitution Principle. This method should not be used.

Returns
int 0 if no further bytes are available. Otherwise returns 1, which suggests (but does not guarantee) that additional bytes are available.
Throws
IOException if this stream is closed or an error occurs

close

Added in API level 9
void close ()

Closes the underlying input stream and discards any remaining uncompressed data.

Throws
IOException

mark

Added in API level 9
void mark (int limit)

This operation is not supported and does nothing.

Parameters
limit int: the number of bytes that can be read from this stream before the mark is invalidated.

markSupported

Added in API level 9
boolean markSupported ()

Returns false because DeflaterInputStream does not support mark/reset.

Returns
boolean true if mark() and reset() are supported, false otherwise.

read

Added in API level 9
int read ()

Reads a byte from the compressed input stream. The result will be a byte of compressed data corresponding to an uncompressed byte or bytes read from the underlying stream.

Returns
int the byte or -1 if the end of the stream has been reached.
Throws
IOException

read

Added in API level 9
int read (byte[] buffer, 
                int byteOffset, 
                int byteCount)

Reads up to byteCount bytes of compressed data into a byte buffer. The result will be bytes of compressed data corresponding to an uncompressed byte or bytes read from the underlying stream. Returns the number of bytes read or -1 if the end of the compressed input stream has been reached.

Parameters
buffer byte
byteOffset int
byteCount int
Returns
int
Throws
IOException

reset

Added in API level 9
void reset ()

This operation is not supported and throws IOException.

Throws
IOException

skip

Added in API level 9
long skip (long byteCount)

Skips byteCount bytes in this stream. Subsequent calls to read will not return these bytes unless reset is used. This implementation skips byteCount bytes in the filtered stream.

Note: if n > Integer.MAX_VALUE, this stream will only attempt to skip Integer.MAX_VALUE bytes.

Parameters
byteCount long
Returns
long the number of bytes actually skipped.
Throws
IOException
This site uses cookies to store your preferences for site-specific language and display options.

Hooray!

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.