Added in API level 1

GZIPInputStream

open class GZIPInputStream : InflaterInputStream
kotlin.Any
   ↳ java.io.InputStream
   ↳ java.io.FilterInputStream
   ↳ java.util.zip.InflaterInputStream
   ↳ java.util.zip.GZIPInputStream

This class implements a stream filter for reading compressed data in the GZIP file format.

Summary

Constants
static Int

GZIP header magic number.

Public constructors

Creates a new input stream with the specified buffer size.

Creates a new input stream with a default buffer size.

Public methods
open Unit

Closes this input stream and releases any system resources associated with the stream.

open Int
read(buf: ByteArray!, off: Int, len: Int)

Reads uncompressed data into an array of bytes.

Inherited functions
Properties
CRC32!

CRC-32 for uncompressed data.

Boolean

Indicates end of input stream.

Inherited properties

Constants

GZIP_MAGIC

Added in API level 1
static val GZIP_MAGIC: Int

GZIP header magic number.

Value: 35615

Public constructors

GZIPInputStream

Added in API level 1
GZIPInputStream(
    in: InputStream!,
    size: Int)

Creates a new input stream with the specified buffer size. Android-note: Android limits the number of UnbufferedIO operations that can be performed, so consider using buffered inputs with this class. More information can be found in the UnbufferedIO and StrictMode documentation.

Parameters
in InputStream!: the input stream
size Int: the input buffer size
Exceptions
java.util.zip.ZipException if a GZIP format error has occurred or the compression method used is unsupported
java.io.IOException if an I/O error has occurred
java.lang.IllegalArgumentException if size <= 0

GZIPInputStream

Added in API level 1
GZIPInputStream(in: InputStream!)

Creates a new input stream with a default buffer size.

Parameters
in InputStream!: the input stream
Exceptions
java.util.zip.ZipException if a GZIP format error has occurred or the compression method used is unsupported
java.io.IOException if an I/O error has occurred

Public methods

close

Added in API level 1
open fun close(): Unit

Closes this input stream and releases any system resources associated with the stream.

Exceptions
java.lang.Exception if this resource cannot be closed
java.io.IOException if an I/O error has occurred

read

Added in API level 1
open fun read(
    buf: ByteArray!,
    off: Int,
    len: Int
): Int

Reads uncompressed data into an array of bytes. If len is not zero, the method will block until some input can be decompressed; otherwise, no bytes are read and 0 is returned.

Parameters
b the buffer into which the data is read
off Int: the start offset in the destination array b
len Int: the maximum number of bytes read
buf ByteArray!: the buffer into which the data is read
Return
Int the actual number of bytes read, or -1 if the end of the compressed input stream is reached
Exceptions
java.io.IOException if an I/O error has occurred.
java.lang.NullPointerException If buf is null.
java.lang.IndexOutOfBoundsException If off is negative, len is negative, or len is greater than buf.length - off
java.util.zip.ZipException if the compressed input data is corrupt.

Properties

crc

Added in API level 1
protected var crc: CRC32!

CRC-32 for uncompressed data.

eos

Added in API level 1
protected var eos: Boolean

Indicates end of input stream.