Compressing RMI data transfer using!_NEWLINE_!ZipOutputStream and ZipInputStream
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Ben_Chen
Posted On:   Wednesday, March 6, 2002 08:11 AM

After reading Tony Sintes article on Compress your data, took his instructions step by step and applied it to a RMI application I had. I seem to be getting an Error, java.util.zip.ZipException: no current ZIP entry When attempting to start the client. After hours of investigating and trial and error, I was unsuccessful to find a work around to the problem, I was wondering if Tony could possibly point out mistakes. Or certain criteria which have to be met for the given piece of code to function. The closest to working attempt which I got was when I created a class CompressionInputStream extends FilterInputStream public Compres   More>>

After reading Tony Sintes article on Compress your data,
took his instructions step by step and applied it to a
RMI application I had.

I seem to be getting an Error, java.util.zip.ZipException:
no current ZIP entry When attempting to start the client.

After hours of investigating and trial and error,
I was unsuccessful to find a work around to the
problem, I was wondering if Tony could possibly
point out mistakes. Or certain criteria which have
to be met for the given piece of code to function.

The closest to working attempt which I got was when
I created a

			
class CompressionInputStream extends FilterInputStream

public CompressionInputStream(InputStream in) throws IOException
{
super(new ZipInputStream(in));
}

class CompressionOutputStream extends FilterOutputStream

public CompressionOutputStream(OutputStream out) throws IOException
{
super(new ZipOutputStream(out));
}


to replace the ZipInputStream and ZipOutputStream,

Then I over written the read a write methods to
insert zip entries for each attempt to write.


			

public int read(byte b[], int off, int len) throws IOException
{
ZipEntry tempEntry = ((ZipInputStream)in).getNextEntry();
return ((ZipInputStream)in).read(b, off, len);;
}


public synchronized void write(byte b[], int off, int len) throws IOException
{
// for (int x = 0 ; x < 9000000 ; x++) { System.out.print("");}

((ZipOutputStream)out).putNextEntry(new ZipEntry("temp" + temp));
temp++;
((ZipOutputStream)out).write(b,off,len);
((ZipOutputStream)out).closeEntry();
}



I keep a static variable temp inorder to create unique ZipEntry names for each
write operation.

This seems to work ONLY if server doesn't attempt to write data to the
ZipStream twice before the client gets a chance to reads the first piece
written.

Therefore, when the for loop is uncomment out, the code seems to work.
I was wondering is there is a way to stop the write process until the previous entry written to the ZipStream has already been read by the client?
It seems impossible to obtain that information from the ZipOutputStream.

Also, is there another way to do this? A way which works? Unlike mine.

Thanks!    <<Less

Re: Compressing RMI data transfer using!_NEWLINE_!ZipOutputStream and ZipInputStream

Posted By:   Christopher_Schultz  
Posted On:   Wednesday, March 6, 2002 10:54 AM

Try using a GzipOutputStream. They are more "stream-friendly" than the ZipOutputStreams.
About | Sitemap | Contact