GZIPOutputStream: write(byte[] buf, int off, int len)
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.zip.GZIPOutputStream;
public class Main {
public static void main(String[] args) throws Exception {
int sChunk = 8192;
String zipname = "a.gz";
FileOutputStream out = new FileOutputStream(zipname);
GZIPOutputStream zipout = new GZIPOutputStream(out);
byte[] buffer = new byte[sChunk];
FileInputStream in = new FileInputStream(args[0]);
int length;
while ((length = in.read(buffer, 0, sChunk)) != -1)
zipout.write(buffer, 0, length);
in.close();
zipout.close();
}
}
Related examples in the same category