Examples of InflaterInputStream


Examples of java.util.zip.InflaterInputStream

        @Override
        public void run() {
          try {
            if(br.receive()) {
              ByteArrayInputStream bais = new ByteArrayInputStream(data);
              InflaterInputStream dis = new InflaterInputStream(bais);
              SimpleFieldSet fs;
              try {
                fs = new SimpleFieldSet(new BufferedReader(new InputStreamReader(dis, "UTF-8")), false, false);
              } catch (UnsupportedEncodingException e) {
                synchronized(DarknetPeerNode.this) {
View Full Code Here

Examples of java.util.zip.InflaterInputStream

            throw new MatlabIOException("Compressed buffer length miscalculated!");
        }
       
        //instead of standard Inflater class instance, use an inflater input
        //stream... gives a great boost to the performance
        InflaterInputStream iis = new InflaterInputStream( new InputStream() {

            int limit = numOfBytes;
            @Override
            public synchronized int read() throws IOException
            {
                // TODO Auto-generated method stub
                throw new RuntimeException("Not yet implemented");
            }
            public synchronized int read(byte[] bytes, int off, int len) throws IOException {
                if ( !(limit > 0) )
                {
                    return -1;
                }
                len = Math.min(len, limit);
                // Read only what's left
                buf.get(bytes, off, len);
                limit -= len;
                return len;
            }       
        });
       
        //process data decompression
        byte[] result = new byte[128];
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        int i;
        try
        {
            do
            {
                i = iis.read(result, 0, result.length);
                int len = Math.max(0, i);
                baos.write(result, 0, len);
            }
            while ( i > 0 );
        }
        catch ( IOException e )
        {
            throw new MatlabIOException("Could not decompress data: " + e );
        }
        finally
        {
            iis.close();
        }
        //create a ByteBuffer from the deflated data
        ByteBuffer out = ByteBuffer.wrap( baos.toByteArray() );
        //with proper byte ordering
        out.order( byteOrder );
View Full Code Here

Examples of java.util.zip.InflaterInputStream

    }
    System.out.println();
  }
 
  private static void writeBundle(InputStream is, boolean decompress, String header) throws IOException {
    InputStream zipStream = decompress ? new InflaterInputStream(is) : is;
    File tf = File.createTempFile("hg-bundle-", null);
    FileOutputStream fos = new FileOutputStream(tf);
    fos.write(header.getBytes());
    int r;
    byte[] buf = new byte[8*1024];
 
View Full Code Here

Examples of java.util.zip.InflaterInputStream

        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

Examples of java.util.zip.InflaterInputStream

            aldus.top = header.bounds.y;
            aldus.right = header.bounds.x + header.bounds.width;
            aldus.bottom = header.bounds.y + header.bounds.height;
            aldus.write(out);

            InflaterInputStream inflater = new InflaterInputStream( is );
            byte[] chunk = new byte[4096];
            int count;
            while ((count = inflater.read(chunk)) >=0 ) {
                out.write(chunk,0,count);
            }
            inflater.close();
            return out.toByteArray();
        } catch (IOException e){
            throw new RuntimeException(e);
        }
    }
View Full Code Here

Examples of java.util.zip.InflaterInputStream

            InputStream is = new ByteArrayInputStream( rawdata );
            Header header = new Header();
            header.read(rawdata, CHECKSUM_SIZE);
            is.skip(header.getSize() + CHECKSUM_SIZE);

            InflaterInputStream inflater = new InflaterInputStream( is );
            byte[] chunk = new byte[4096];
            int count;
            while ((count = inflater.read(chunk)) >=0 ) {
                out.write(chunk,0,count);
            }
            inflater.close();
            return out.toByteArray();
        } catch (IOException e){
            throw new RuntimeException(e);
        }
    }
View Full Code Here

Examples of java.util.zip.InflaterInputStream

        // Parse prior IDAT chunks
        InputStream seqStream =
            new SequenceInputStream(streamVec.elements());
        InputStream infStream =
            new InflaterInputStream(seqStream, new Inflater());
        dataStream = new DataInputStream(infStream);
       
        // Create an empty WritableRaster
        int depth = bitDepth;
        if ((colorType == PNG_COLOR_GRAY) &&
View Full Code Here

Examples of java.util.zip.InflaterInputStream

        try {
            int length = chunk.getLength() - textIndex;
            byte[] data = chunk.getData();
            InputStream cis =
                new ByteArrayInputStream(data, textIndex, length);
            InputStream iis = new InflaterInputStream(cis);
           
            int c;
            while ((c = iis.read()) != -1) {
                value += (char)c;
            }
           
            ztextKeys.add(key);
            ztextStrings.add(value);
View Full Code Here

Examples of java.util.zip.InflaterInputStream

                int read = in.read( buf );
                while ( read != -1 && read < nDumpSize )
                    read += in.read( buf, read, buf.length );
                ByteArrayInputStream bin = new ByteArrayInputStream( buf );

                InputStream in1 = new InflaterInputStream( bin );
                int bytesToDump = -1;
                HexDump.dump( in1, out, 0, bytesToDump );

                recordBytesRemaining -= nDumpSize;
                remainingBytes -= nDumpSize;
View Full Code Here

Examples of java.util.zip.InflaterInputStream

            try {
                inflater.inflate(new byte[1000]);

                // no error decompressing the first 100 bytes, so we
                // assume the "zlib"-variant was used.
                result = new InflaterInputStream(bStream);
            } catch (DataFormatException e) {
                // there was an error decompressing the first 100 bytes,
                // so we assume the "gzip/raw"-variant was used.
                result = new InflaterInputStream(bStream, new Inflater(true));
            } finally {
                inflater.end();
            }
        } else {
            result = in;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.