Uncompressing a File in the GZIP Format
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.util.zip.GZIPInputStream;
public class Main {
public static void main(String[] argv) throws Exception {
String inFilename = "infile.gzip";
GZIPInputStream in = new GZIPInputStream(new FileInputStream(inFilename));
String outFilename = "outfile";
OutputStream out = new FileOutputStream(outFilename);
byte[] buf = new byte[1024];
int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}
in.close();
out.close();
}
}
Related examples in the same category