GZIPInputStream: read(byte[] buf, int off, int len) : GZIPInputStream « java.util.zip « Java by API






GZIPInputStream: read(byte[] buf, int off, int len)

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.zip.GZIPInputStream;

public class MainClass {
  public static int sChunk = 8192;

  public static void main(String[] args) throws Exception {
    String zipname = "data.txt.gz";
    String source = "data.txt.gz";
    GZIPInputStream zipin;

    FileInputStream in = new FileInputStream(zipname);
    zipin = new GZIPInputStream(in);

    byte[] buffer = new byte[sChunk];
    // decompress the file
    FileOutputStream out = new FileOutputStream(source);
    int length;
    while ((length = zipin.read(buffer, 0, sChunk)) != -1)
      out.write(buffer, 0, length);
    out.close();

    zipin.close();
  }
}

           
       








Related examples in the same category

1.new GZIPInputStream(InputStream in)