Article View: borland.public.jbuilder.java.api
Article #1390Re: Error when Infalting data. java.util.zip.DataFormatException: incomplete literal/length tree
From: Joi Ellis [TeamB]
Date: Wed, 13 Feb 2002 15:10
Date: Wed, 13 Feb 2002 15:10
53 lines
2884 bytes
2884 bytes
S.Thanika <thanika@firstecom.com> wrote:
> Hi,
> I am trying to inflate a data which is Base64 decoded. And it show me the
> following error
> java.util.zip.DataFormatException: incomplete literal/length tree
> at java.util.zip.Inflater.inflate(Inflater.java:195)
> at java.util.zip.Inflater.inflate(Inflater.java:212)
> at
> com.basebean.Visa3DSpec.VisaCompression.decompress(VisaCompression.java:74)
> at com.basebean.Visa3DSpec.Visa3d.main(Visa3d.java:111)
> Following is my program
> public String decompress(String inStr){
> byte[] b2 = new byte[inStr.length()];
I'm not certain, but this line may be your problem. Remember that chars in
Java are two-bytes long. String.length() is telling you how long the String
is in chars, not bytes. Your byte array is half the length it needs to be.
Also note that a String type probably isn't the best type to use for storing compressed data, either.
> b2 = inStr.getBytes();
> Inflater decompresser = new Inflater();
> decompresser.setInput(b2,0,b2.length);
> int xxxxx =0;
> try {
> xxxxx = decompresser.inflate(b2);
> }
> 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;
> }
> I have tried using other method of decompression, and it seem there is
> a problem. I am out of my wits, can anyone help me...
--
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:
<3c6a81d8_2@dnews>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!isdnet!fr.clara.net!heighliner.fr.clara.net!newsfeed01.sul.t-online.de!t-online.de!dnews!not-for-mailReferences:
<3c6a1fe1_1@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-13 07:15:24 PST
Sender: Joi Ellis <joi@artoo.gyles19.visi.com>
Message-ID: <3c6a81d8_2@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>
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: 13 Feb 2002 07:10:16 -0800
X-Trace: dnews 1013613016 209.98.6.107 (13 Feb 2002 07:10:16 -0800)
Lines: 53
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!isdnet!fr.clara.net!heighliner.fr.clara.net!newsfeed01.sul.t-online.de!t-online.de!dnews!not-for-mail