see below!

Tom Rochelle wrote:

> Hi Everyone:
>
> Any ideas as to why the following code doesn't work?  It generates the following 
>exception:
> I've concluded that the writeObject with the GZIPOutputStream in the mix doesn't 
>generate
> the byte array that should be generated.  Thus, an exception is thrown when the byte 
>array is
> decompressed.  I'm hoping to generate an array of bytes containing the compressed 
>object.
> Using jdk1.2.2.
>
> Per my reading of O'Reilly's Java Examples in a Nutshell pp 266-7 and
> Sun's  http://forum.java.sun.com/forum?[EMAIL PROTECTED]^[email protected]/0
>
> the code should work.
>
> the Exception:
>
> Exception is Caught EOFException while reading the stream header
> java.io.StreamCorruptedException: Caught EOFException while reading the stream header
>         at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:727)
>         at java.io.ObjectInputStream.<init>(ObjectInputStream.java:165)
>         at examples.ejb.basic.rc.TestIt.main(TestIt.java, Compiled Code)
>
> the code:
>
> import java.util.*;
> import java.util.zip.*;
> import java.io.*;
>
>  public class TestIt {
>
>   public static void main(String[] args)
>   {
>     try
>     {
>           Vector names = new Vector();
>           String fred = "fred";
>           String skip = "skip";
>           String lisa = "lisa";
>
>           names.addElement(fred);
>           names.addElement(skip);
>           names.addElement(lisa);
>
>           ByteArrayOutputStream baos = new ByteArrayOutputStream();
>           GZIPOutputStream gos       = new GZIPOutputStream( baos );
>           ObjectOutputStream oos     = new ObjectOutputStream( gos );
>           oos.writeObject( names );
>           oos.flush();

            gos.finish(); //see the JavaDoc for GZIPOutputStream.
            // the rest unchanged.

Francis.

--
Francis Pouatcha

MATHEMA Software GmbH
http://www.mathema.de

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to