Ungzip with GZIPInputStream
import java.io.FileInputStream; import java.io.FileOutputStream; import java.util.zip.GZIPInputStream; public class Main { public static void main(String[] args) throws Exception { FileInputStream fin = new FileInputStream("a.gz"); GZIPInputStream gzin = new GZIPInputStream(fin); FileOutputStream fout = new FileOutputStream("a.dat"); for (int c = gzin.read(); c != -1; c = gzin.read()) { fout.write(c); } fout.close(); } }