java.util.zip

Class InflaterInputStream

Implemented Interfaces:
AutoCloseable, Closeable
Known Direct Subclasses:
GZIPInputStream, ZipInputStream

public class InflaterInputStream
extends FilterInputStream

This filter stream is used to decompress data compressed in the "deflate" format. The "deflate" format is described in RFC 1951. This stream may form the basis for other decompression filters, such as the GZIPInputStream.
Since:
1.1

Field Summary

protected byte[]
buf
Byte array used as a buffer
protected Inflater
inf
Decompressor for this filter
protected int
len
Size of buffer

Fields inherited from class java.io.FilterInputStream

in

Constructor Summary

InflaterInputStream(InputStream in)
Create an InflaterInputStream with the default decompresseor and a default buffer size.
InflaterInputStream(InputStream in, Inflater inf)
Create an InflaterInputStream with the specified decompresseor and a default buffer size.
InflaterInputStream(InputStream in, Inflater inf, int size)
Create an InflaterInputStream with the specified decompresseor and a specified buffer size.

Method Summary

int
available()
Returns 0 once the end of the stream (EOF) has been reached.
void
close()
Closes the input stream
protected void
fill()
Fills the buffer with more data to decompress.
void
mark(int readLimit)
boolean
markSupported()
int
read()
Reads one byte of decompressed data.
int
read(byte[] b, int off, int len)
Decompresses data into the byte array
void
reset()
long
skip(long n)
Skip specified number of bytes of uncompressed data

Methods inherited from class java.io.FilterInputStream

available, close, mark, markSupported, read, read, read, reset, skip

Methods inherited from class java.io.InputStream

available, close, mark, markSupported, read, read, read, reset, skip

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Details

buf

protected byte[] buf
Byte array used as a buffer

inf

protected Inflater inf
Decompressor for this filter

len

protected int len
Size of buffer

Constructor Details

InflaterInputStream

public InflaterInputStream(InputStream in)
Create an InflaterInputStream with the default decompresseor and a default buffer size.
Parameters:
in - the InputStream to read bytes from

InflaterInputStream

public InflaterInputStream(InputStream in,
                           Inflater inf)
Create an InflaterInputStream with the specified decompresseor and a default buffer size.
Parameters:
in - the InputStream to read bytes from
inf - the decompressor used to decompress data read from in

InflaterInputStream

public InflaterInputStream(InputStream in,
                           Inflater inf,
                           int size)
Create an InflaterInputStream with the specified decompresseor and a specified buffer size.
Parameters:
in - the InputStream to read bytes from
inf - the decompressor used to decompress data read from in
size - size of the buffer to use

Method Details

available

public int available()
            throws IOException
Returns 0 once the end of the stream (EOF) has been reached. Otherwise returns 1.
Overrides:
available in interface FilterInputStream

close

public void close()
            throws IOException
Closes the input stream
Specified by:
close in interface Closeable
close in interface AutoCloseable
Overrides:
close in interface FilterInputStream

fill

protected void fill()
            throws IOException
Fills the buffer with more data to decompress.

mark

public void mark(int readLimit)
Overrides:
mark in interface FilterInputStream

markSupported

public boolean markSupported()
Overrides:
markSupported in interface FilterInputStream

read

public int read()
            throws IOException
Reads one byte of decompressed data. The byte is in the lower 8 bits of the int.
Overrides:
read in interface FilterInputStream

read

public int read(byte[] b,
                int off,
                int len)
            throws IOException
Decompresses data into the byte array
Overrides:
read in interface FilterInputStream
Parameters:
b - the array to read and decompress data into
off - the offset indicating where the data should be placed
len - the number of bytes to decompress

reset

public void reset()
            throws IOException
Overrides:
reset in interface FilterInputStream

skip

public long skip(long n)
            throws IOException
Skip specified number of bytes of uncompressed data
Overrides:
skip in interface FilterInputStream
Parameters:
n - number of bytes to skip

InflaterInputStream.java - Input stream filter for decompressing Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.