Cette classe implémente un filtre de flux pour lire les données compressées au format de fichier GZIP. Constructeurs
GZIPInputStream(InputStream dans) :
Crée un nouveau flux d'entrée avec une taille de tampon par défaut.
GZIPInputStream(InputStream en taille entière) :
Crée un nouveau flux d'entrée avec la taille de tampon spécifiée. Méthodes :
void close() :
Closes this input stream and releases any system resources associated with the stream.
Syntax : public void close() throws IOException Specified by: close in interface Closeable Specified by: close in interface AutoCloseable Overrides: close in class InflaterInputStream Throws: IOException
int read(byte[] buf int off int len) :
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.
Syntax : public int read(byte[] buf int off int len) throws IOException Overrides: read in class InflaterInputStream Parameters: buf - the buffer into which the data is read off - the start offset in the destination array b len - the maximum number of bytes read Returns: the actual number of bytes read or -1 if the end of the compressed input stream is reached Throws: NullPointerException IndexOutOfBoundsException ZipException IOException
Méthodes héritées de la classe java.util.zip.InflaterInputStream marque de remplissage disponible saut de réinitialisation de lecture pris en charge Méthodes héritées de la classe java.io.FilterInputStream lire Méthodes héritées de la classe java.lang.Object clone est égal à finaliser getClass hashCode notify notifyAll toString wait wait wait Programme : Java
//Java program demonstrating GZipInputStream methods importjava.io.FileInputStream;importjava.io.FileOutputStream;importjava.io.IOException;importjava.util.Arrays;importjava.util.zip.GZIPInputStream;classGZipInputStreamDemo{publicstaticvoidmain(String[]args)throwsIOException{FileInputStreamfis=newFileInputStream('file.txt');GZIPInputStreamgzis=newGZIPInputStream(fis);//Uncompressed FileContents //01234567890 byteb[]=newbyte[10];//skipping 1 byte gzis.skip(1);//illustrating available() and //read(byte b[]int offint len) if(gzis.available()!=-1)gzis.read(b);System.out.println(Arrays.toString(b));//closing the stream gzis.close();}}