September 04, 2010, 01:40:14 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  Home Help Media Affiliates Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: How to compress a datastream using gzip?  (Read 902 times)
0 Members and 1 Guest are viewing this topic.
Arkie
Javaforums.net Admin
Senior Member
*

Reputation: 16
Developer @ Javaforums.net
Offline Offline
Posts: 2620
Referrals: 13

WWW Awards
« on: March 18, 2009, 06:18:42 PM »

Hi,
 
I'm trying to compress an object using gzip but i get this error when i want to read in the data:

java.io.EOFException
        at java.io.ObjectInputStream$PeekInputStream.readFully(Unknown Source)
        at java.io.ObjectInputStream$BlockDataInputStream.readShort(Unknown Source)
        at java.io.ObjectInputStream.readStreamHeader(Unknown Source)
        at java.io.ObjectInputStream.<init>(Unknown Source)
 
this is the code:

Code
GeSHi (java):
  1. new FileInputStream("image.gz"))));
  2. System.out.println(ois.readObject());
Created by GeSHI 1.0.7.20

 
And this is how i write out the data

Code
GeSHi (java):
  1. new FileOutputStream("image.gz")));
  2. out.writeObject(img);
  3.  
  4. out.close();
  5. System.out.println(out);
Created by GeSHI 1.0.7.20

output:
java.io.ObjectOutputStream@ef22f8
java.io.ObjectOutputStream@1ffb8dc
java.io.ObjectOutputStream@54172f

writing seems to work but i don't know how to read it back in. Gzip seems to be the best solution to compress an single object but if  there is a better way let me know.
 
Logged

Java and .NET developer

To students: It doesn't matter how hard you've studied; the material won't be on the exam anyway.

Fan of http://www.retardedweblogger.com
Oh man, too much stuff to do in so little time.

http://img222.imageshack....707/arkietomatoesmall.jpg
Blizzcon 2k9 Grubby and Cassandra Ng engaged ! <3
Triple D, eerste Denken Dan Doen
Javaforums.net :: a community about Java software development.
« on: March 18, 2009, 06:18:42 PM »

Your Ad Here
 Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.10 | SMF © 2006-2009, Simple Machines LLC
TinyPortal v0.9.8 © Bloc
Valid XHTML 1.0! Valid CSS!
Page created in 0.214 seconds with 32 queries.

Google visited last this page August 30, 2010, 09:22:39 AM