Package java.util.zip

Examples of java.util.zip.InflaterInputStream


        public String getXmlBuffer() throws ReportProcessingException
        {
            try
            {
                final byte[] zippedData = xmlBuffer.getRaw();
                final InputStreamReader reader = new InputStreamReader(new InflaterInputStream(new ByteArrayInputStream(zippedData, 0, xmlBuffer.getLength())), "UTF-16");
                final StringWriter writer = new StringWriter((zippedData.length / 2) + 1);
                IOUtils.getInstance().copyWriter(reader, writer);
                return writer.toString();
            }
            catch (IOException e)
View Full Code Here


        public Reader getXmlAsReader() throws ReportProcessingException
        {
            try
            {
                final byte[] zippedData = xmlBuffer.getRaw();
                return new InputStreamReader(new InflaterInputStream(new ByteArrayInputStream(zippedData, 0, xmlBuffer.getLength())), "UTF-16");
            }
            catch (IOException e)
            {
                throw new ReportProcessingException("Failed to copy buffer", e);
            }
View Full Code Here

                        break;
                    }
                }
                in = z;
            } else if ("DEFLATE".equals(compressionAlgorithm)) {
                in = new InflaterInputStream(in);
            } else if ("LZF".equals(compressionAlgorithm)) {
                in = new LZFInputStream(in);
            } else if (compressionAlgorithm != null) {
                throw DbException.get(ErrorCode.UNSUPPORTED_COMPRESSION_ALGORITHM_1, compressionAlgorithm);
            }
View Full Code Here

        // convert from string to bytes for decompressing
        byte[] compressedDat = Base64.decodeBase64( data.getBytes() );

        final ByteArrayInputStream in = new ByteArrayInputStream( compressedDat );
        final Inflater inflater = new Inflater();
        final InflaterInputStream iStream = new InflaterInputStream( in, inflater );
        final char cBuffer[] = new char[4096];
        StringBuilder sBuf = new StringBuilder();
        try {
            InputStreamReader iReader = new InputStreamReader( iStream, CONVERTER_UTF8 );
            while ( true ) {
View Full Code Here

                        if ("gzip".equalsIgnoreCase(comp)) {
                            final int len = layerWidth * layerHeight * 4;
                            is = new GZIPInputStream(bais, len);
                        } else if ("zlib".equalsIgnoreCase(comp)) {
                            is = new InflaterInputStream(bais);
                        } else if (comp != null && !comp.isEmpty()) {
                            throw new IOException("Unrecognized compression method \"" + comp + "\" for map layer " + ml.getName());
                        } else {
                            is = bais;
                        }
View Full Code Here

                                    try {
                                        errorStream = new GZIPInputStream(errorStream, 4096);
                                    } catch (IOException e) {
                                    }
                                } else if (encoding.toLowerCase().trim().equals("deflate")) {
                                    errorStream = new InflaterInputStream(errorStream, new Inflater(true), 4096);
                                }
                            }

                            InputStreamReader reader = new InputStreamReader(errorStream);
                            char[] buffer = new char[4096];
                            int b;
                            while ((b = reader.read(buffer)) > -1) {
                                sb.append(buffer, 0, b);
                            }
                            reader.close();

                            errorContent = sb.toString();
                        } catch (IOException e) {
                            errorContent = "Unable to retrieve content: " + e.getMessage();
                        }
                    }
                } else {
                    try {
                        errorStream.close();
                    } catch (IOException e) {
                    }
                }

                if (responseStream != null) {
                    try {
                        responseStream.close();
                    } catch (IOException e) {
                    }
                }

                return;
            }

            // get the stream length
            String lengthStr = getHeader("Content-Length");
            if (lengthStr != null) {
                try {
                    length = new BigInteger(lengthStr);
                } catch (NumberFormatException e) {
                }
            }

            if (stream != null) {
                String encoding = getContentEncoding();
                if (encoding != null) {
                    if (encoding.toLowerCase().trim().equals("gzip")) {
                        // if the stream is gzip encoded, decode it
                        length = null;
                        try {
                            stream = new GZIPInputStream(stream, 4096);
                        } catch (IOException e) {
                            errorContent = e.getMessage();
                            stream = null;
                            try {
                                responseStream.close();
                            } catch (IOException ec) {
                            }
                        }
                    } else if (encoding.toLowerCase().trim().equals("deflate")) {
                        // if the stream is deflate encoded, decode it
                        length = null;
                        stream = new InflaterInputStream(stream, new Inflater(true), 4096);
                    }
                }

                String transferEncoding = getContentTransferEncoding();
                if ((stream != null) && (transferEncoding != null)
View Full Code Here

            try {
                ByteSequence bodyAsBytes = getContent();
                if (bodyAsBytes != null) {
                    is = new ByteArrayInputStream(bodyAsBytes);
                    if (isCompressed()) {
                        is = new InflaterInputStream(is);
                    }
                    DataInputStream dataIn = new DataInputStream(is);
                    text = MarshallingSupport.readUTF8(dataIn);
                    dataIn.close();
                    setContent(null);
View Full Code Here

        if (object == null && getContent() != null) {
            try {
                ByteSequence content = getContent();
                InputStream is = new ByteArrayInputStream(content);
                if (isCompressed()) {
                    is = new InflaterInputStream(is);
                }
                DataInputStream dataIn = new DataInputStream(is);
                ClassLoadingAwareObjectInputStream objIn = new ClassLoadingAwareObjectInputStream(dataIn);
                try {
                    object = (Serializable)objIn.readObject();
View Full Code Here

//      dataInputs[slotIndex] = new DataInputStream(new ByteArrayInputStream(uncompressed));
    Inflater inflater = new Inflater(true);
    inflaters[slotIndex] = inflater;  // save to be able to call end() when done.
    ByteArrayInputStream baiStream = new ByteArrayInputStream(b);     
    int zipBufSize = Math.max(32768, bytesCompr);
    InflaterInputStream iis = new InflaterInputStream(baiStream, inflater, zipBufSize);
    dataInputs[slotIndex] = new DataInputStream(new BufferedInputStream(iis, zipBufSize));
  }
View Full Code Here

        ByteArrayOutputStream out = new ByteArrayOutputStream();
        ByteArrayInputStream bis = new ByteArrayInputStream(data);
        Header header = new Header();
        header.read(data, pos);
        bis.skip(pos + header.getSize());
        InflaterInputStream inflater = new InflaterInputStream( bis );
        byte[] chunk = new byte[4096];
        int count;
        while ((count = inflater.read(chunk)) >=0 ) {
            out.write(chunk,0,count);
        }
        inflater.close();
        return out.toByteArray();
    }
View Full Code Here

TOP

Related Classes of java.util.zip.InflaterInputStream

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.