ObjectInputStream and GZIPInputStream working together - newbie

R

R

Hello everybody.

I'm a newbie.

I have my simple client/server application.
I was using the ObjectInputStream/ObjectOutputStream for transmiting
serialized data between computers.

It was working and then I thought of compressing my data.

So I did sth like this:

// get stream from socket
is = c.getInputStream();
ObjectInputStream ois = null;
try {
// create new InputStream
ois = new ObjectInputStream(new GZIPInputStream(is));
} catch (IOException e) {
e.printStackTrace();
}
// debug prints
System.out.println("is is: " + is);
System.out.println("ois is: " + ois);

but it isn't working at all
the results are:

Server: 127.0.0.1, port: 1112
Client: 127.0.0.1, port: 33091
java.io.EOFException
at java.util.zip.GZIPInputStream.readUByte(GZIPInputStream.java:200)
at java.util.zip.GZIPInputStream.readUShort(GZIPInputStream.java:190)
at java.util.zip.GZIPInputStream.readHeader(GZIPInputStream.java:130)
at java.util.zip.GZIPInputStream.<init>(GZIPInputStream.java:58)
at java.util.zip.GZIPInputStream.<init>(GZIPInputStream.java:68)
at MultiClient.Start(MultiClient.java:133)
at MultiClient.main(MultiClient.java:29)

oos is: java.io_ObjectOutputStream@c9ba38
os is: java.net.SocketOutputStream@12152e6

is is: java.net.SocketInputStream@1d99a4d
ois is: null

where osi is ObjectInputStream = null

I can see that the GZIPInputStream constructor calls various read
methods.

And this is crucial moment because SocketInputStream can (and in most
cases is) empty at that moment.

How can I combine those two streams to work together?

thanks in advance for any help

best regrads
R
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,195
Latest member
tewan

Latest Threads

Top