Example usage for java.util.zip InflaterOutputStream InflaterOutputStream

List of usage examples for java.util.zip InflaterOutputStream InflaterOutputStream

Introduction

In this page you can find the example usage for java.util.zip InflaterOutputStream InflaterOutputStream.

Prototype

public InflaterOutputStream(OutputStream out) 

Source Link

Document

Creates a new output stream with a default decompressor and buffer size.

Usage

From source file:de.siegmar.logbackgelf.GelfUdpAppenderTest.java

private JsonNode receiveCompressedMessage() throws IOException {
    final ByteArrayOutputStream bos = new ByteArrayOutputStream();
    final InflaterOutputStream inflaterOutputStream = new InflaterOutputStream(bos);

    inflaterOutputStream.write(server.getReceivedData());
    inflaterOutputStream.close();//from   w w w  . j av a2 s.  co m

    return new ObjectMapper().readTree(bos.toByteArray());
}

From source file:de.tntinteractive.portalsammler.engine.SecureStore.java

public byte[] getDocument(final DocumentInfo metadata) throws IOException {
    final Map<String, String> pointer = this.index.getFilePosition(metadata);
    final byte[] buffer = this.readAndDecrypt(pointer.get("f"));
    final int offset = Integer.parseInt(pointer.get("o"));
    final int size = Integer.parseInt(pointer.get("s"));

    final ByteArrayOutputStream result = new ByteArrayOutputStream();
    final InflaterOutputStream inflate = new InflaterOutputStream(result);
    inflate.write(buffer, offset, size);
    inflate.close();/*from  w  w  w. j av  a2 s  .c  o m*/

    return result.toByteArray();
}

From source file:org.diorite.nbt.NbtOutputStream.java

/**
 * Create new inflated nbt output stream for given stream, and write nbt tag to it.
 *
 * @param tag          nbt tag to write.
 * @param outputStream output stream to be used.
 *
 * @return created NbtOutputStream./*ww  w  .ja  v  a  2  s .  c o m*/
 *
 * @throws IOException if any write operation failed.
 */
public static NbtOutputStream writeInflated(final NbtTag tag, final OutputStream outputStream)
        throws IOException {
    final NbtOutputStream out = new NbtOutputStream(new InflaterOutputStream(outputStream));
    out.write(tag);
    return out;
}

From source file:org.diorite.nbt.NbtOutputStream.java

/**
 * Create new inflated output stream for given file, and write nbt tag to it.
 *
 * @param tag  nbt tag to write.//  w  w  w.j  a  v  a  2 s  .  c om
 * @param file data file to be used.
 *
 * @return created NbtOutputStream.
 *
 * @throws IOException if any write operation failed.
 */
public static NbtOutputStream writeInflated(final NbtTag tag, final File file) throws IOException {
    createFile(file);
    final NbtOutputStream out = new NbtOutputStream(
            new InflaterOutputStream(new FileOutputStream(file, false)));
    out.write(tag);
    return out;
}

From source file:org.diorite.nbt.NbtOutputStream.java

/**
 * Create new inflated output stream for given file, and write nbt tag to it.
 *
 * @param tag    nbt tag to write.//from  w  w w  . java  2s.c  o  m
 * @param file   data file to be used.
 * @param append if new data should be appended to existing one.
 *
 * @return created NbtOutputStream.
 *
 * @throws IOException if any write operation failed.
 */
public static NbtOutputStream writeInflated(final NbtTag tag, final File file, final boolean append)
        throws IOException {
    createFile(file);
    final NbtOutputStream out = new NbtOutputStream(
            new InflaterOutputStream(new FileOutputStream(file, append)));
    out.write(tag);
    return out;
}

From source file:org.diorite.nbt.NbtOutputStream.java

/**
 * Create new inflated nbt output stream for given stream.
 *
 * @param outputStream stream to be used.
 *
 * @return created NbtOutputStream./*from   w  w w  .  j a v a  2  s . c  o m*/
 */
public static NbtOutputStream getInflated(final OutputStream outputStream) {
    return new NbtOutputStream(new InflaterOutputStream(outputStream));
}

From source file:org.diorite.nbt.NbtOutputStream.java

/**
 * Create new inflated nbt output stream for given file.
 *
 * @param file file to be used.//  ww w  .  j a v a 2 s .  c  o m
 *
 * @return created NbtOutputStream.
 *
 * @throws IOException if any file operation failed.
 */
public static NbtOutputStream getInflated(final File file) throws IOException {
    createFile(file);
    return new NbtOutputStream(new InflaterOutputStream(new FileOutputStream(file, false)));
}

From source file:org.diorite.nbt.NbtOutputStream.java

/**
 * Create new inflated nbt output stream for given file.
 *
 * @param file   file to be used.//  w  w  w.  j a v  a 2s  .c om
 * @param append if new data should be appended to existing one.
 *
 * @return created NbtOutputStream.
 *
 * @throws IOException if any file operation failed.
 */
public static NbtOutputStream getInflated(final File file, final boolean append) throws IOException {
    createFile(file);
    return new NbtOutputStream(new InflaterOutputStream(new FileOutputStream(file, append)));
}

From source file:org.sejda.sambox.output.ObjectsStreamTest.java

@Test
public void addItem() throws IOException {
    victim.addItem(context.createIndirectReferenceFor(COSInteger.ZERO));
    victim.addItem(context.createIndirectReferenceFor(COSInteger.THREE));
    victim.prepareForWriting();/*from  w w w  .java  2s.  com*/
    assertEquals(COSName.OBJ_STM.getName(), victim.getNameAsString(COSName.TYPE));
    assertEquals(2, victim.getInt(COSName.N));
    assertEquals(8, victim.getInt(COSName.FIRST));
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    IOUtils.copy(victim.getFilteredStream(), new InflaterOutputStream(out));
    byte[] data = new byte[] { 49, 32, 48, 32, 50, 32, 50, 32, 48, 32, 51, 32 };
    assertArrayEquals(data, out.toByteArray());
}