Most visited

Recently visited

Added in API level 9

DeflaterInputStream

public class DeflaterInputStream
extends FilterInputStream

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


Implements an input stream filter for compressing data in the "deflate" compression format.

See also:

Summary

Fields

protected final byte[] buf

Input buffer for reading compressed data.

protected final Deflater def

Compressor for this stream.

Inherited fields

From class java.io.FilterInputStream

Public constructors

DeflaterInputStream(InputStream in)

Creates a new input stream with a default compressor and buffer size.

DeflaterInputStream(InputStream in, Deflater defl)

Creates a new input stream with the specified compressor and a default buffer size.

DeflaterInputStream(InputStream in, Deflater defl, int bufLen)

Creates a new input stream with the specified compressor and buffer size.

Public methods

int available()

Returns 0 after EOF has been reached, otherwise always return 1.

void close()

Closes this input stream and its underlying input stream, discarding any pending uncompressed data.

void mark(int limit)

This operation is not supported.

boolean markSupported()

Always returns false because this input stream does not support the mark() and reset() methods.

int read()

Reads a single byte of compressed data from the input stream.

int read(byte[] b, int off, int len)

Reads compressed data into a byte array.

void reset()

This operation is not supported.

long skip(long n)

Skips over and discards data from the input stream.

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

Input buffer for reading compressed data.

def

Added in API level 9
Deflater def

Compressor for this stream.

Public constructors

DeflaterInputStream

Added in API level 9
DeflaterInputStream (InputStream in)

Creates a new input stream with a default compressor and buffer size.

Parameters
in InputStream: input stream to read the uncompressed data to
Throws
NullPointerException if in is null

DeflaterInputStream

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

Creates a new input stream with the specified compressor and a default buffer size.

Parameters
in InputStream: input stream to read the uncompressed data to
defl Deflater: compressor ("deflater") for this stream
Throws
NullPointerException if in or defl is null

DeflaterInputStream

Added in API level 9
DeflaterInputStream (InputStream in, 
                Deflater defl, 
                int bufLen)

Creates a new input stream with the specified compressor and buffer size.

Parameters
in InputStream: input stream to read the uncompressed data to
defl Deflater: compressor ("deflater") for this stream
bufLen int: compression buffer size
Throws
IllegalArgumentException if bufLen is <= 0
NullPointerException if in or defl is null

Public methods

available

Added in API level 9
int available ()

Returns 0 after EOF has been reached, otherwise always return 1.

Programs should not count on this method to return the actual number of bytes that could be read without blocking

Returns
int zero after the end of the underlying input stream has been reached, otherwise always returns 1
Throws
IOException if an I/O error occurs or if this stream is already closed

close

Added in API level 9
void close ()

Closes this input stream and its underlying input stream, discarding any pending uncompressed data.

Throws
IOException if an I/O error occurs

mark

Added in API level 9
void mark (int limit)

This operation is not supported.

Parameters
limit int: maximum bytes that can be read before invalidating the position marker

markSupported

Added in API level 9
boolean markSupported ()

Always returns false because this input stream does not support the mark() and reset() methods.

Returns
boolean false, always

read

Added in API level 9
int read ()

Reads a single byte of compressed data from the input stream. This method will block until some input can be read and compressed.

Returns
int a single byte of compressed data, or -1 if the end of the uncompressed input stream is reached
Throws
IOException if an I/O error occurs or if this stream is already closed

read

Added in API level 9
int read (byte[] b, 
                int off, 
                int len)

Reads compressed data into a byte array. This method will block until some input can be read and compressed.

Parameters
b byte: buffer into which the data is read
off int: starting offset of the data within b
len int: maximum number of compressed bytes to read into b
Returns
int the actual number of bytes read, or -1 if the end of the uncompressed input stream is reached
Throws
IndexOutOfBoundsException if len > b.length - off
IOException if an I/O error occurs or if this input stream is already closed

reset

Added in API level 9
void reset ()

This operation is not supported.

Throws
IOException always thrown

skip

Added in API level 9
long skip (long n)

Skips over and discards data from the input stream. This method may block until the specified number of bytes are read and skipped. Note: While n is given as a long, the maximum number of bytes which can be skipped is Integer.MAX_VALUE.

Parameters
n long: number of bytes to be skipped
Returns
long the actual number of bytes skipped
Throws
IOException if an I/O error occurs or if this stream is already closed

Hooray!