/* Gzip.java */import java.io.*;import java.util.zip.*;public class Gzip { private static void gzip(File f) throws IOException { System.out.println( "Gzip "+f ) ; FileInputStream in = new FileInputStream( f ); GZIPOutputStream out = new GZIPOutputStream( new FileOutputStream( f+".gz" )); byte[] buffer = new byte[4096]; int bytes_read; while((bytes_read = in.read(buffer)) != -1) out.write(buffer, 0, bytes_read); in.close(); out.close(); } public static void main(String[] args) { if (args.length < 1) { System.err.println("Usage: java Gzip file..."); return; } for (int i = 0; i < args.length; i++) { File f = new File(args[i]); try { gzip(f); } catch (IOException x) { System.err.println(f + ": " + x); } } }}