Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-02-2008, 12:15 PM
Member
 
Join Date: Dec 2007
Posts: 14
hemanthjava is on a distinguished road
java.util.zip.ZipException: invalid bit length repeat EXCEPTION
My requirement is I need to compress a Big String and send it from server to Client. At the client end I need to decompress it back to get the original String

The size of my compressed String is 30447

When I uncompress it. I get this error

java.util.zip.ZipException: invalid bit length repeat

The following below is the code used for Compressing and Uncompressing a String.

Code:
private static void decompressString(byte[] baFileContentCompressed) { ByteArrayOutputStream baos; ByteArrayInputStream bais = new ByteArrayInputStream( baFileContentCompressed); GZIPInputStream zis = null; byte[] buffer = new byte[8192]; // the result byte[] baFileContentDecompressed = null; baos = new ByteArrayOutputStream(); try { buffer = new byte[1024]; try { zis = new GZIPInputStream(bais); for (int len; (len = zis.read(buffer, 0, 1024)) != -1;) { baos.write(buffer, 0, len); } zis.close(); bais.close(); baos.close(); baFileContentDecompressed = baos.toByteArray(); } catch (IOException e) { e.printStackTrace(); } System.out.println(new String(baFileContentDecompressed)); } catch (Exception e) { e.printStackTrace(); } } private static byte[] compressInputString(String testData) { byte[] baFileContent = testData.getBytes(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); GZIPOutputStream zos; try { zos = new GZIPOutputStream(baos); zos.write(baFileContent); zos.close(); baos.close(); } catch (IOException e) { e.printStackTrace(); } byte[] baFileContentCompressed = baos.toByteArray(); return baFileContentCompressed; }


The exception is thrown when
Code:
len = zis.read(buffer, 0, 1024)
is invoked

Need some help here.

Regards,
Bob
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-02-2008, 03:15 PM
Norm's Avatar
Senior Member
 
Join Date: Jun 2008
Location: SW MO, USA
Posts: 709
Norm is on a distinguished road
Could you write a small standalone, self contained program that gets the error that we could copy and execute?
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
nested <ui:repeat> - problem hackerofcrackers JavaServer Faces 0 06-20-2008 11:06 AM
Exception in thread "main" java.util.NoSuchElementException ragav New To Java 4 06-08-2008 03:19 PM
[SOLVED] Exception in thread &quot;main&quot; java.util.NoSuchElementException thevoice New To Java 5 05-14-2008 02:43 PM
java.util Java Tutorial Java Tutorials 1 02-07-2008 02:46 PM
java.io.IOException: invalid header field osval Advanced Java 1 08-07-2007 12:09 AM


All times are GMT +3. The time now is 01:23 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org