import   java.io.*; 
import   java.util.zip.*; 
public   class   GZIProc   { 
     public   static   void   main(String[]   args)   { 
            
           byte[]   b1   ,b2   =   null; 
           try   { 
               
                 BufferedInputStream   in   =   new   BufferedInputStream(   new   FileInputStream(args[0])); 
                 ByteArrayOutputStream   bout   =   new   ByteArrayOutputStream(); 
                 GZIPOutputStream   out   =   new   GZIPOutputStream(bout); 
                 ObjectOutputStream   oout   =   new   ObjectOutputStream(out); 
                 //   读取源文件 
                 b1   =   new   byte[in.available()];       
                 in.read(b1,0,b1.length);                   
                 System.out.println( "压缩前:\n "   +   new   String(b1)); 
                                    
                 //   压缩 
                 //out.write(b1,0,   b1.length); 
                 oout.writeObject(new   String(b1)); 
                 oout.flush(); 
                 oout.close(); 
                  
                 //   读取压缩字节流 
                 b2   =   bout.toByteArray(); 
                  
                 System.out.println( "压缩后:\n "   +   new   String(b2)); 
                 //   关闭数据流 
                 in.close(); 
                           
                 //   解压 
                 ObjectInputStream   in2   =   new  
ObjectInputStream(new   GZIPInputStream(new  
ByteArrayInputStream(b2))); 
                 byte[]   b3   =   ((String)in2.readObject()).getBytes(); 
                 in2.close(); 
                  
                 //   输出 
                 System.out.println(   new   String(b3)); 
           }   catch(Exception   e)   { 
                 e.printStackTrace(); 
           } 
     } 
}