mercredi 24 juin 2015

ZipException: Invalid Literal/lengths Set when Reading from GZipStream

For this segment of my program:

 String content = s3Details[2];

 InputStream in = IOUtils.toInputStream(content, Charset.forName("UTF-8"));
 Base64InputStream base64InputStream = new Base64InputStream(in);
 GZIPInputStream gzipInputStream = new GZIPInputStream(base64InputStream);

 Reader decoder = new InputStreamReader(gzipInputStream, Charset.forName("UTF-8"));
 BufferedReader reader = new BufferedReader(decoder);
 String line;
 while ((line = reader.readLine()) != null){
        System.out.println(line);
 }

Essentially, content is a string that has been base 64 encoded and then gzipped. It is parsed from the message body of an AWS SQS message. When I try to unzip as follows, and read from the gzip input stream, I get the error invalid literals/lengths set.

java.util.zip.ZipException: invalid literal/lengths set

and when I just read from base64inputStream, I get crazy binary (as expected), and when I read from the gzipInputStream w/o base64 decoding it, I get an error complaining about the stream not being in gzip format.

Any suggestions?




Aucun commentaire:

Enregistrer un commentaire