Package java.util.zip

Examples of java.util.zip.GZIPInputStream


    private static InputStream prepareBody(final RequestHeader header, final InputStream in) throws IOException {
        InputStream body = in;
        // data may be compressed
        final String bodyEncoding = header.get(HeaderFramework.CONTENT_ENCODING);
        if(HeaderFramework.CONTENT_ENCODING_GZIP.equalsIgnoreCase(bodyEncoding) && !(body instanceof GZIPInputStream)) {
            body = new GZIPInputStream(body);
            // length of uncompressed data is unknown
            header.remove(HeaderFramework.CONTENT_LENGTH);
        } else {
            // ensure the end of data (if client keeps alive the connection)
            final long clength = header.getContentLength();
View Full Code Here


     * @throws IOException
     */
    static byte[] decompress(byte[] compressedData) throws IOException {
       
        ByteArrayInputStream bis = new ByteArrayInputStream(compressedData);
        GZIPInputStream in = new GZIPInputStream(bis);
       
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
       
        byte[] transferBuffer = new byte[4096];
        int read = 0;
        do {
            read = in.read(transferBuffer);
            if (read != -1) {
                bos.write(transferBuffer, 0, read);
            }
        } while (read != -1);
        in.close();
               
        in.close();
        bos.close();
       
        return bos.toByteArray();
    }
View Full Code Here

     * @throws IOException
     */
    public static byte[] decompress(byte[] compressedData) throws IOException {
       
        ByteArrayInputStream bis = new ByteArrayInputStream(compressedData);
        GZIPInputStream in = new GZIPInputStream(bis);
       
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
       
        byte[] transferBuffer = new byte[4096];
        int read = 0;
        do {
            read = in.read(transferBuffer);
            if (read != -1) {
                bos.write(transferBuffer, 0, read);
            }
        } while (read != -1);
        in.close();
               
        in.close();
        bos.close();
       
        return bos.toByteArray();
    }
View Full Code Here

    public static void main(String[] args) {
        File f = new File(args[0]);
        SurrogateReader sr;
        try {
            InputStream is = new BufferedInputStream(new FileInputStream(f));
            if (f.getName().endsWith(".gz")) is = new GZIPInputStream(is);
            sr = new SurrogateReader(is, 1);

            Thread t = new Thread(sr, "Surrogate-Reader " + f.getAbsolutePath());
            t.start();
            DCEntry s;
View Full Code Here

     * @throws IOException
     */
    public static byte[] decompress(byte[] compressedData) throws IOException {
       
        ByteArrayInputStream bis = new ByteArrayInputStream(compressedData);
        GZIPInputStream in = new GZIPInputStream(bis);
       
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
       
        byte[] transferBuffer = new byte[4096];
        int read = 0;
        do {
            read = in.read(transferBuffer);
            if (read != -1) {
                bos.write(transferBuffer, 0, read);
            }
        } while (read != -1);
        in.close();
               
        in.close();
        bos.close();
       
        return bos.toByteArray();
    }
View Full Code Here

        Document[] docs = null;
        try {          
            int read = 0;
            final byte[] data = new byte[1024];
           
            final GZIPInputStream zippedContent = new GZIPInputStream(source);
           
            tempFile = File.createTempFile("gunzip","tmp");
            tempFile.deleteOnExit();
           
            // creating a temp file to store the uncompressed data
            final FileOutputStream out = new FileOutputStream(tempFile);
           
            // reading gzip file and store it uncompressed
            while ((read = zippedContent.read(data, 0, 1024)) != -1) {
                out.write(data, 0, read);
            }
            zippedContent.close();
            out.close();
           
            // creating a new parser class to parse the unzipped content
            docs = TextParser.parseSource(location,null,null,tempFile);
        } catch (final Exception e) {   
View Full Code Here

            final ResponseHeader header = new ResponseHeader(client.getHttpResponse().getAllHeaders());
            final String contentMimeType = header.mime();
   
            InputStream contentStream = client.getContentstream();
            if (contentMimeType != null && (contentMimeType.equals("application/x-gzip") || contentMimeType.equals("application/gzip"))) {
                contentStream = new GZIPInputStream(contentStream);
            }
            final ByteCountInputStream counterStream = new ByteCountInputStream(contentStream, null);
            return sitemapParser.parse(counterStream);
        } catch (IOException e) {
            throw e;
View Full Code Here

                if (b != 'B') throw new IOException("Invalid bz2 content.");
                b = is.read();
                if (b != 'Z') throw new IOException("Invalid bz2 content.");
                is = new CBZip2InputStream(is);
            } else if (sourcefile.getName().endsWith(".gz")) {
                is = new GZIPInputStream(is);
            }
            BufferedReader r = new BufferedReader(new java.io.InputStreamReader(is, "UTF-8"), 4 * 1024 * 1024);
            String t;
            StringBuilder sb = new StringBuilder();
            boolean page = false, text = false;
View Full Code Here

            return moved;
        } else {
            try {
                InputStream is = new BufferedInputStream(new FileInputStream(infile));
                if (s.endsWith(".gz")) {
                    is = new GZIPInputStream(is);
                }
                processSurrogate(is, infile.getName());
            } catch (final IOException e) {
                Log.logException(e);
            } finally {
View Full Code Here

    }
   
    private void inputStream(final File file) throws IOException {
      InputStream is = new FileInputStream(file);
      if (file.getName().endsWith(".gz")) {
            is = new GZIPInputStream(is);
        }
        final BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
        String l;
        try {
            while ((l = reader.readLine()) != null) {
View Full Code Here

TOP

Related Classes of java.util.zip.GZIPInputStream

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.