🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

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

#1392
From: S.Thanika
Date: Thu, 14 Feb 2002 06:55
117 lines
4666 bytes
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.

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

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


sun.misc.BASE64Decoder dec = new sun.misc.BASE64Decoder();
byte[] strinf = dec.decodeBuffer(encstr);
String str = xx.inflate(strinf);

public  String decompress(byte[] inStr){
      byte[] b2 = new byte[inStr.length];
      b2 = inStr;
      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;
    }



"Joi Ellis [TeamB]" <joi@aravox.com> wrote in message
news:3c6a81d8_2@dnews...
> 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.


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.320 / Virus Database: 179 - Release Date: 1/30/02
Technical Details
Message-ID: <3c6b6053_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
References: <3c6a1fe1_1@dnews> <3c6a81d8_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-13 23:10:12 PST
From: "S.Thanika" <thanika@firstecom.com>
Newsgroups: borland.public.jbuilder.java.api
References: <3c6a1fe1_1@dnews> <3c6a81d8_2@dnews>
Subject: Re: Error when Infalting data. java.util.zip.DataFormatException: incomplete literal/length tree
Date: Thu, 14 Feb 2002 14:55:15 +0800
Lines: 119
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.50.4807.1700
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4807.1700
NNTP-Posting-Host: 203.198.196.105
Message-ID: <3c6b6053_2@dnews>
X-Trace: dnews 1013669971 203.198.196.105 (13 Feb 2002 22:59:31 -0800)
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