Example usage for org.apache.commons.compress.compressors.gzip GzipCompressorOutputStream flush

List of usage examples for org.apache.commons.compress.compressors.gzip GzipCompressorOutputStream flush

Introduction

In this page you can find the example usage for org.apache.commons.compress.compressors.gzip GzipCompressorOutputStream flush.

Prototype

public void flush() throws IOException 

Source Link

Document

Flushes this output stream and forces any buffered output bytes to be written out.

Usage

From source file:msec.org.GzipUtil.java

static public void zip(String srcFile, String destFile) throws Exception {
    GzipCompressorOutputStream out = new GzipCompressorOutputStream(new FileOutputStream(destFile));
    FileInputStream in = new FileInputStream(srcFile);
    byte[] buf = new byte[10240];
    while (true) {
        int len = in.read(buf);
        if (len <= 0) {
            break;
        }//from w  w  w  .j  av  a 2 s. c om
        out.write(buf, 0, len);
    }
    out.flush();
    out.close();
    in.close();
}

From source file:msec.org.GzipUtil.java

static public void zip(String srcFile) throws Exception {
    GzipCompressorOutputStream out = new GzipCompressorOutputStream(new FileOutputStream(srcFile + ".gz"));
    FileInputStream in = new FileInputStream(srcFile);
    byte[] buf = new byte[10240];
    while (true) {
        int len = in.read(buf);
        if (len <= 0) {
            break;
        }/*from w ww .j  a  va  2 s.  c o m*/
        out.write(buf, 0, len);
    }
    out.flush();
    out.close();
    in.close();
}