All Downloads are FREE. Search and download functionalities are using the official Maven repository.

edu.isi.nlp.io.GZIPByteSink Maven / Gradle / Ivy

The newest version!
package edu.isi.nlp.io;

import static com.google.common.base.Preconditions.checkNotNull;

import com.google.common.io.ByteSink;
import com.google.common.io.Files;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.util.zip.GZIPOutputStream;

public final class GZIPByteSink extends ByteSink {

  private GZIPByteSink(final ByteSink wrappedByteSink) {
    this.wrappedByteSink = checkNotNull(wrappedByteSink);
  }

  public static ByteSink gzipCompress(final ByteSink byteSink) {
    return new GZIPByteSink(byteSink);
  }

  public static ByteSink gzipCompress(final File f) {
    return gzipCompress(Files.asByteSink(f));
  }

  @Override
  public OutputStream openStream() throws IOException {
    return new GZIPOutputStream(wrappedByteSink.openBufferedStream());
  }

  private final ByteSink wrappedByteSink;
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy