Code example for GZIPOutputStream

Methods: writeclosefinish

0
 
	public static byte[] gzipCompress(byte[] data) throws IOException {
		ByteArrayOutputStream os = new ByteArrayOutputStream();
		GZIPOutputStream gos = null;
		try { 
			gos = new GZIPOutputStream(os);
			gos.write(data);
			gos.finish();
			return os.toByteArray();
		} finally { 
			os.close();
			if (gos != null)
				gos.close();
		} 
 
	} 
 
	public static byte[] gzipDecompress(byte[] compressed) throws IOException {
		ByteArrayInputStream is = new ByteArrayInputStream(compressed);
		GZIPInputStream gis = null;
Stop searching for code, let great code find you!  Add Codota to your java IDE