Java 8 InflaterInputStream - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 InflaterInputStream class.

This code example shows how to use the following methods:
 
    @Override 
    public void processMessage(final ChannelAssociation channelAssociation, final InputStream inputStream) throws IOException { 
        EjbLogger.EJB3_INVOCATION_LOGGER.trace("Received a compressed message stream"); 
        // use a inflater inputstream to inflate the contents 
        final InputStream inflaterInputStream = new InflaterInputStream(inputStream); 
        // let the EJB protocol handler process the stream 
        this.ejbProtocolHandler.processMessage(channelAssociation.getChannel(), inflaterInputStream); 
    } 
} 
8
CodeRank
This code example shows how to use the following methods:skip, getNextEntry
        zentry = zis.getNextEntry();
        zentry = zis.getNextEntry();
        long s = zis.skip(1025);
        assertTrue("invalid skip: " + s, s == 1025);
 
        ZipInputStream zis = new ZipInputStream(new ByteArrayInputStream(
                zipBytes));
        zis.getNextEntry();
        long skipLen = dataBytes.length / 2;
        assertEquals("Assert 0: failed valid skip", skipLen, zis.skip(skipLen));
        zis.skip(dataBytes.length);
        assertEquals("Assert 1: performed invalid skip", 0, zis.skip(1));
        assertEquals("Assert 2: failed zero len skip", 0, zis.skip(0));
        try { 
            zis.skip(-1);
            fail("Assert 3: Expected Illegal argument exception");
        } catch (IllegalArgumentException e) {
            // Expected 
        } 
 
7
CodeRank
This code example shows how to use the following methods:
  protected void ensureInflated() { 
    if (compressed != null) {
      try { 
        ByteArrayInputStream deflated = new ByteArrayInputStream(compressed);
        DataInput inflater =
          new DataInputStream(new InflaterInputStream(deflated));
        readFieldsCompressed(inflater);
        compressed = null;
      } catch (IOException e) {
        throw new RuntimeException(e);
      } 
    } 
  } 
 
  /** Subclasses implement this instead of {@link #readFields(DataInput)}. */ 
  protected abstract void readFieldsCompressed(DataInput in)
    throws IOException; 
 
  @Override 
  public final void write(DataOutput out) throws IOException {
7
CodeRank
This code example shows how to use the following methods:close
        } 
 
        // 3. 解压缩 
        ByteArrayInputStream bais = new ByteArrayInputStream(plaintext);
        Inflater inf = new Inflater(false);
        InflaterInputStream iis = new InflaterInputStream(bais, inf);
 
        // 4. 反序列化 
        try { 
            @SuppressWarnings("unchecked") 
            Map<String, Object> attrs = (Map<String, Object>) serializer.deserialize(iis);
            return attrs; 
        } catch (Exception e) {
            throw new SessionEncoderException("Failed to parse session state", e);
        } finally { 
            try { 
                iis.close();
            } catch (IOException e) {
            } 
 

6
CodeRank
This code example shows how to use the following methods:
	} 
 
	public static byte[] inflateByteArray(byte[] input) {
		try { 
			ByteArrayInputStream bos = new ByteArrayInputStream(input);
			InflaterInputStream in = new InflaterInputStream(bos);
 
			byte[] uncompressedData = ERXFileUtilities.bytesFromInputStream(in);
			return uncompressedData;
		} 
		catch (IOException e) {
			return null; 
		} 
	} 
 
	public static String deflateString(String source) {
		try { 
			return new String(deflateByteArray(source.getBytes(CharEncoding.UTF_8)), CharEncoding.UTF_8);
		} 
		catch (UnsupportedEncodingException e) {
6
CodeRank
This code example shows how to use the following methods:
            byte[] data = new byte[length - 1];
            if (dataStream.read(data) < length - 1) {
                throw new DataException("MCRegion file does not contain " 
                        + x + "," + z + " in full");
            } 
            return new InflaterInputStream(new ByteArrayInputStream(data));
        } else { 
            throw new DataException("MCRegion chunk at " 
                    + x + "," + z + " has an unsupported version of " + version);
        } 
    } 
 
    /** 
     * Get the offset for a chunk. May return 0 if it doesn't exist. 
     *  
     * @param x 
     * @param z 
     * @return 
     */ 
    private int getOffset(int x, int z) {
6
CodeRank
This code example shows how to use the following methods:read, skip
	/** 
	 * @tests java.util.zip.InflaterInputStream#skip(long) 
	 */ 
	public void test_skipJ() throws IOException { 
		InputStream is = Support_Resources.getStream("hyts_available.tst");
		InflaterInputStream iis = new InflaterInputStream(is);
 
		// Tests for skipping a negative number of bytes. 
		try { 
			iis.skip(-3);
			fail("IllegalArgumentException not thrown");
		} catch (IllegalArgumentException e) {
            // Expected 
		} 
		assertEquals("Incorrect Byte Returned.", 5, iis.read());
 
		try { 
			iis.skip(Integer.MIN_VALUE);
			fail("IllegalArgumentException not thrown");
		} catch (IllegalArgumentException e) {

6
CodeRank
This code example shows how to use the following methods:
        } 
    } 
 
    public Object unmarshal(Exchange exchange, InputStream stream) throws Exception {
        InputStream is = exchange.getIn().getMandatoryBody(InputStream.class);
        InflaterInputStream unzipInput = new InflaterInputStream(is);
         
        // Create an expandable byte array to hold the inflated data 
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        try { 
            IOHelper.copy(unzipInput, bos);
            return bos.toByteArray();
        } finally { 
            // must close input streams 
            IOHelper.close(is, unzipInput);
        } 
    } 
 
} 
6
CodeRank
This code example shows how to use the following methods:skip, getNextEntry
        zentry = zis.getNextEntry();
        zentry = zis.getNextEntry();
        long s = zis.skip(1025);
        assertTrue("invalid skip: " + s, s == 1025);
 
        ZipInputStream zis = new ZipInputStream(new ByteArrayInputStream(
                zipBytes));
        zis.getNextEntry();
        long skipLen = dataBytes.length / 2;
        assertEquals("Assert 0: failed valid skip", skipLen, zis.skip(skipLen));
        zis.skip(dataBytes.length);
        assertEquals("Assert 1: performed invalid skip", 0, zis.skip(1));
        assertEquals("Assert 2: failed zero len skip", 0, zis.skip(0));
        try { 
            zis.skip(-1);
            fail("Assert 3: Expected Illegal argument exception");
        } catch (IllegalArgumentException e) {
            // Expected 
        } 
 
6
CodeRank
This code example shows how to use the following methods:
	} 
 
	public static byte[] inflateByteArray(byte[] input) {
		try { 
			ByteArrayInputStream bos = new ByteArrayInputStream(input);
			InflaterInputStream in = new InflaterInputStream(bos);
 
			byte[] uncompressedData = ERXFileUtilities.bytesFromInputStream(in);
			return uncompressedData;
		} 
		catch (IOException e) {
			return null; 
		} 
	} 
 
	public static String deflateString(String source) {
		try { 
			return new String(deflateByteArray(source.getBytes(CharEncoding.UTF_8)), CharEncoding.UTF_8);
		} 
		catch (UnsupportedEncodingException e) {
6
CodeRank

Related Java 8 InflaterInputStream Questions & Answers:

See Code Examples for Java 8 InflaterInputStream Methods: