Results 1 to 2 of 2
  1. #1
    hemanthjava is offline Member
    Join Date
    Dec 2007
    Posts
    22
    Rep Power
    0

    Default 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
    Java Code:
    len = zis.read(buffer, 0, 1024)
    is invoked

    Need some help here.

    Regards,
    Bob

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,903
    Rep Power
    25

    Default

    Could you write a small standalone, self contained program that gets the error that we could copy and execute?

Similar Threads

  1. nested <ui:repeat> - problem
    By hackerofcrackers in forum JavaServer Faces (JSF)
    Replies: 0
    Last Post: 06-20-2008, 11:06 AM
  2. Replies: 4
    Last Post: 06-08-2008, 03:19 PM
  3. Replies: 5
    Last Post: 05-14-2008, 02:43 PM
  4. java.util
    By Java Tutorial in forum Java Tutorial
    Replies: 1
    Last Post: 02-07-2008, 02:46 PM
  5. java.io.IOException: invalid header field
    By osval in forum Advanced Java
    Replies: 1
    Last Post: 08-07-2007, 12:09 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •