Link to home
Start Free TrialLog in
Avatar of piou
piouFlag for Greece

asked on

GZIPInputStream reading

JDK's docs are horrible for those classes!

So, GZIPing is straightforward. But unzipping?

ByteArrayOutputStream bos = new ByteArrayOutputStream();
               GZIPOutputStream gos = new GZIPOutputStream(bos);
               ObjectOutputStream oos = new ObjectOutputStream(gos);
               oos.writeObject(data);
               System.out.println("zipped size = "+bos.size());
               
               ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
               System.out.println("available size = "+bis.available());
               GZIPInputStream gis = new GZIPInputStream(bis);
               
               ObjectInputStream ois = new ObjectInputStream(gis);

This obviously won't work. So how am I gonna get the decompressed data to the ObjectInputStream to get my object back?
ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of piou

ASKER

Cheers again! :)
No worries :-)