1 2 import java.io.*; 3 import com.jcraft.jzlib.*; 4 5 public class test_stream_deflate_inflate{ 6 public static void main(String [] args){ 7 try{ 8 ByteArrayOutputStream out=new ByteArrayOutputStream(); 9 ZOutputStream zOut=new ZOutputStream(out, JZlib.Z_BEST_COMPRESSION); 10 ObjectOutputStream objOut=new ObjectOutputStream(zOut); 11 String hello="Hello World!"; 12 objOut.writeObject(hello); 13 zOut.close(); 14 15 ByteArrayInputStream in=new ByteArrayInputStream(out.toByteArray()); 16 ZInputStream zIn=new ZInputStream(in); 17 ObjectInputStream objIn=new ObjectInputStream(zIn); 18 System.out.println(objIn.readObject()); 19 } 20 catch (Exception e){ 21 e.printStackTrace(); 22 } 23 } 24 } 25 | Popular Tags |