Code example for GZIPOutputStream

Methods: closefinish

0
 */ 
public class KnowledgeUtils { 
 
  public static byte[] serializeOntology(InputStream input) throws IOException {
    ByteArrayOutputStream byteArrayOutput = new ByteArrayOutputStream((int)(input.available() * 0.5));
    GZIPOutputStream gzipStream = new GZIPOutputStream(byteArrayOutput);
    IOUtils.copy(input, gzipStream);
    gzipStream.finish();
    gzipStream.close();
    return byteArrayOutput.toByteArray();
  } 
 
  public static InputStream deserializeOntology(byte[] input) throws IOException {
    return new GZIPInputStream(new ByteArrayInputStream(input));
  } 
 
} 
Stop searching for code, let great code find you!  Add Codota to your java IDE