Results 1 to 2 of 2
- 07-02-2008, 11:15 AM #1
Member
- Join Date
- Dec 2007
- Posts
- 22
- Rep Power
- 0
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.
Java 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
is invokedJava Code:len = zis.read(buffer, 0, 1024)
Need some help here.
Regards,
Bob
- 07-02-2008, 02:15 PM #2
Similar Threads
-
nested <ui:repeat> - problem
By hackerofcrackers in forum JavaServer Faces (JSF)Replies: 0Last Post: 06-20-2008, 10:06 AM -
Exception in thread "main" java.util.NoSuchElementException
By ragav in forum New To JavaReplies: 4Last Post: 06-08-2008, 02:19 PM -
[SOLVED] Exception in thread "main" java.util.NoSuchElementException
By thevoice in forum New To JavaReplies: 5Last Post: 05-14-2008, 01:43 PM -
java.util
By Java Tutorial in forum Java TutorialReplies: 1Last Post: 02-07-2008, 01:46 PM -
java.io.IOException: invalid header field
By osval in forum Advanced JavaReplies: 1Last Post: 08-06-2007, 11:09 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks