Java 8 InflaterOutputStream - 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 InflaterOutputStream class.

This code example shows how to use the following methods:close, flush
 
    /** 
     * @tests java.util.zip.InflaterOutputStream#flush() 
     */ 
    public void test_flush() throws IOException { 
        InflaterOutputStream ios = new InflaterOutputStream(os);
        ios.close();
        try { 
            ios.flush();
            fail("Should throw IOException");
        } catch (IOException e) {
            // expected 
        } 
 
        ios = new InflaterOutputStream(os);
        ios.flush();
        ios.flush();
    } 
 
    /** 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:close, write
        return decodeCubeModel(modelStr);
    } 
 
    public static Cube decodeCubeModel(String encoded) throws IOException {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        OutputStream os = new InflaterOutputStream(baos, new Inflater(false));
        os.write(Base64.decodeBase64(encoded.getBytes("US-ASCII")));
        os.close();
        return parseYamlModel(new String(baos.toByteArray(), "utf-8"));
    } 
 
    public static String encodeCubeModel(String yamlStr) throws IOException {
 
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        Writer w = new OutputStreamWriter(new DeflaterOutputStream(baos, new Deflater(9, false)), "utf-8");
        w.append(yamlStr);
        w.close();
 
        String result = new String(Base64.encodeBase64(baos.toByteArray()), "US-ASCII");
        decodeCubeModel(result);
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
  } 
 
  @Override 
  ByteBuffer decompress(ByteBuffer data) throws IOException {
    ByteArrayOutputStream baos = getOutputBuffer(data.remaining());
    writeAndClose(data, new InflaterOutputStream(baos, getInflater()));
    return ByteBuffer.wrap(baos.toByteArray());
  } 
   
  private void writeAndClose(ByteBuffer data, OutputStream out)
    throws IOException {
    out.write(data.array(), data.position(), data.remaining());
    out.close();
  } 
   
  private Inflater getInflater() {
    if (null == inflater)
      inflater = new Inflater(true);
    inflater.reset();
    return inflater;
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
  @Override 
  public byte[] decompress(byte[] value, int offset, int length)
      throws IOException { 
     
    ByteArrayOutputStream baos = new ByteArrayOutputStream(MathUtils.nextPowOfTwo(2 * length));
    try (OutputStream out = new InflaterOutputStream(baos)) {
      out.write(value, offset, length);
    } finally { 
      IoUtils.closeAll(baos);
    } 
     
    return baos.toByteArray();
  } 
} 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:write
        hex.append("0xf2 0x00 0x11 0x00 0x00");
 
        byte compressed[] = Hex.dehex(hex);
 
        ByteArrayOutputStream bout = new ByteArrayOutputStream(64);
        InflaterOutputStream inflater = new InflaterOutputStream(bout,new Inflater(true));
 
        try 
        { 
            inflater.write(compressed,0,compressed.length);
 
            byte buf[] = bout.toByteArray();
            String actual = new String(buf,Charset.forName("UTF-8"));
            System.out.printf("Actual: \"%s\"%n",actual);
        } 
        catch (Throwable t)
        { 
            t.printStackTrace();
        } 
    } 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
  } 
 
  @Override 
  public ByteBuffer decompress(ByteBuffer data) throws IOException {
    ByteArrayOutputStream baos = getOutputBuffer(data.remaining());
    InflaterOutputStream ios = new InflaterOutputStream(baos, getInflater());
    writeAndClose(data, ios);
    ByteBuffer result = ByteBuffer.wrap(baos.toByteArray());
    return result;
  } 
   
  private void writeAndClose(ByteBuffer data, OutputStream to) throws IOException {
    byte[] input = data.array();
    int offset = data.arrayOffset() + data.position();
    int length = data.remaining();
    try { 
      to.write(input, offset, length);
    } finally { 
      to.close();
    } 
3
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
  } 
 
  @Override 
  ByteBuffer decompress(ByteBuffer data) throws IOException {
    ByteArrayOutputStream baos = getOutputBuffer(data.remaining());
    writeAndClose(data, new InflaterOutputStream(baos, getInflater()));
    return ByteBuffer.wrap(baos.toByteArray());
  } 
   
  private void writeAndClose(ByteBuffer data, OutputStream out)
    throws IOException {
    out.write(data.array(), data.position(), data.remaining());
    out.close();
  } 
   
  private Inflater getInflater() {
    if (null == inflater)
      inflater = new Inflater(true);
    inflater.reset();
    return inflater;
3
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
See Code Examples for Java 8 InflaterOutputStream Methods: