Code example for GZIPOutputStream

Methods: close, write

0
	 * @return ·µ»ØѹËõºóµÄÊý¾Ý 
	 * @throws IOException 
	 */ 
	public static byte[] makeAsByteArray(byte[] data) throws IOException {
		ByteArrayOutputStream out = new ByteArrayOutputStream(data.length);
		GZIPOutputStream zipOut = new GZIPOutputStream(out, Math.max(data.length / 10, 512));
		zipOut.write(data);
		zipOut.close();
		return out.toByteArray();
	} 
 
	/** 
	 * ½«dataÒÔgzip·½Ê½Ñ¹Ëõ£¬²¢·µ»ØÒ»¸ö¿É¶ÁÈ¡µÄInputStream 
	 *  
	 * @param data 
	 * @return ·µ»Ø¿É¶ÁµÄInputStream 
	 * @throws IOException 
	 */ 
	public static InputStream makeAsInputStream(byte[] data) throws IOException {
		return new ByteArrayInputStream(makeAsByteArray(data));
	}