Example usage for java.util.zip GZIPOutputStream finish

List of usage examples for java.util.zip GZIPOutputStream finish

Introduction

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

Prototype

public void finish() throws IOException 

Source Link

Document

Finishes writing compressed data to the output stream without closing the underlying stream.

Usage

From source file:hudson.plugins.project_inheritance.projects.InheritanceProject.java

/**
 * This method dumps the version store as serialized,
 * GZIP compressed, Base64 encoded XML.//from  w  w w.  j a va 2  s. c  om
 * @return
 */
public String doGetVersionsAsCompressedXML() {
    if (this.versionStore == null) {
        return "";
    }
    String xml = this.versionStore.toXML();
    try {
        ByteArrayOutputStream baos = new ByteArrayOutputStream(512);
        BASE64EncoderStream b64s = new BASE64EncoderStream(baos);
        GZIPOutputStream gos = new GZIPOutputStream(b64s);
        gos.write(xml.getBytes());
        gos.finish();
        gos.close();
        return baos.toString();
    } catch (IOException ex) {
        return "";
    }

}