🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.api
Article #1393

Re: Error when Infalting data. java.util.zip.DataFormatException: incomplete literal/length tree

#1393
From: Joi Ellis [TeamB]
Date: Thu, 14 Feb 2002 15:00
95 lines
4583 bytes
S.Thanika <thanika@firstecom.com> wrote:
> Hi,

>         The data I received is via an HTTPS Post.  And I store the value of
> the compress data into a string. But if Java handles strings and char
> differently, what is the best way. Coz I tried using byte[] to store the
> data and it is not successful.

> Please take note before compressing, I have to decode the data which is
> encode in Base64.

>         I used the sun.misc.Base64Decoder to decode.

Hrm.  I avoid using Sun's undocumented stuff.  Here's a search I just did
of all the jars bundled with JBuilder.  I'd look into using one of these
public api decoders instead.  I haven't used any of those so I don't have
any favorite to suggest:

./cocoon/lib/xerces_1_2.jar/org/apache/xerces/utils/Base64.class
./extras/castor/castor-0.9.3-xml.jar/org/exolab/castor/util/MimeBase64Decoder.class
./extras/castor/castor-0.9.3-xml.jar/org/exolab/castor/util/MimeBase64Encoder.class
./extras/castor/castor-0.9.3.jar/org/exolab/castor/util/MimeBase64Decoder.class
./extras/castor/castor-0.9.3.jar/org/exolab/castor/util/MimeBase64Encoder.class
./extras/castor/lib/ldapjdk_4.1.jar/netscape/ldap/util/MimeBase64Decoder.class
./extras/castor/lib/ldapjdk_4.1.jar/netscape/ldap/util/MimeBase64Encoder.class
./extras/castor/lib/xerces-J_1.4.0.jar/org/apache/xerces/utils/Base64.class
./extras/jakarta-tomcat-4.0.1-src/lib/tomcat-util.jar/org/apache/tomcat/util/buf/Base64.class
./extras/jdom/lib/xerces.jar/org/apache/xerces/utils/Base64.class
./extras/xalan/xerces.jar/org/apache/xerces/utils/Base64.class
./extras/xerces/xerces.jar/org/apache/xerces/utils/Base64.class
./extras/BorlandXML/lib/xerces.jar/org/apache/xerces/utils/Base64.class


>         FYI. If i don't used any encoding, the following function work but
> if I used an ecoding it does work.

I don't understand this statement.  Did you forget a 'not'?

>          Could some please suggest me an answer.
> Cheers,
> S.Thanika


> sun.misc.BASE64Decoder dec = new sun.misc.BASE64Decoder();
> byte[] strinf = dec.decodeBuffer(encstr);

Okay, so you now have the binary version of the base64 stuff
in strinf, right?  

> String str = xx.inflate(strinf);

What class is xx?  Is String the only type inflate accepts?
How does this relate to your decompress method below? I'm
confused.

> public  String decompress(byte[] inStr){
>       byte[] b2 = new byte[inStr.length];
>       b2 = inStr;

If inStr is coming in as bytes, you don't even
need b2.  I'd try replacing all instances of b2 with
inStr.

>       Inflater decompresser = new Inflater();
>       decompresser.setInput(b2,0,b2.length);
>       int xxxxx =0;
>       try {
>         xxxxx = decompresser.inflate(b2);
>       }

What is xxxxx?  The number of bytes returned?
where is decompressor writing the expanded text?  It can't
be doing it into b2, there won't be enough room!

>       catch (Exception e) {
>         System.out.println("decompress exception ...");
>         e.printStackTrace();
>       }
>       System.out.println("decompress ... " + inStr.length() + " out: " +
> xxxxx);
>       decompresser.reset();
>       decompresser.end();
>       String outStr = new String(b2,0,xxxxx);
>       outStr.trim();
>       return outStr;
>     }



-- 
Joi Ellis (TeamB)               http://www.teamb.com/
No direct email, please.
For best results, post on news server newsgroups.borland.com!
Newsgroup Guidelines: http://www.borland.com/newsgroups/guide.html
Only posts which violate the rules in guide.html are subject to cancelation.
Technical Details
Message-ID: <3c6bd0fd_1@dnews>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-01!supernews.com!feeder.qis.net!news.maxwell.syr.edu!korova.insync.net!enews.sgi.com!news.xtra.co.nz!newsfeeds.ihug.co.nz!ihug.co.nz!dnews!not-for-mail
References: <3c6a1fe1_1@dnews> <3c6a81d8_2@dnews> <3c6b6053_2@dnews>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 1089d0,61819a74cd2046a2
X-Google-Attributes: gid1089d0,public
X-Google-ArrivalTime: 2002-02-14 07:02:13 PST
Sender: Joi Ellis <joi@artoo.gyles19.visi.com>
Message-ID: <3c6bd0fd_1@dnews>
From: "Joi Ellis [TeamB]" <joi@aravox.com>
Subject: Re: Error when Infalting data. java.util.zip.DataFormatException: incomplete literal/length tree
Newsgroups: borland.public.jbuilder.java.api
References: <3c6a1fe1_1@dnews> <3c6a81d8_2@dnews> <3c6b6053_2@dnews>
User-Agent: tin/1.4.5-20010409 ("One More Nightmare") (UNIX) (Linux/2.2.19-6.2.7 (i686))
NNTP-Posting-Host: 209.98.6.107
Date: 14 Feb 2002 07:00:13 -0800
X-Trace: dnews 1013698813 209.98.6.107 (14 Feb 2002 07:00:13 -0800)
Lines: 95
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-01!supernews.com!feeder.qis.net!news.maxwell.syr.edu!korova.insync.net!enews.sgi.com!news.xtra.co.nz!newsfeeds.ihug.co.nz!ihug.co.nz!dnews!not-for-mail