Uncompress 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 source = "s.gzip";
GZIPInputStream in = new GZIPInputStream(new FileInputStream(source));
String target = "outfile";
OutputStream out = new FileOutputStream(target);
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