Here you can find the source of unZip(byte[] input)
Parameter | Description |
---|---|
input | The zip data |
Parameter | Description |
---|---|
UnsupportedEncodingException | The Character Encoding is not supported. |
public static String unZip(byte[] input) throws UnsupportedEncodingException, IOException
//package com.java2s; //License from project: Apache License import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.util.zip.*; public class Main { public static final String CHARACTER_ENCODING_UTF_8 = "UTF-8"; /**/*from w w w . j ava 2 s . c o m*/ * * @param input The zip data * @return The unzip data * @throws UnsupportedEncodingException The Character Encoding is not supported. */ public static String unZip(byte[] input) throws UnsupportedEncodingException, IOException { ByteArrayInputStream inputStream = new ByteArrayInputStream(input); InflaterInputStream in = new InflaterInputStream(inputStream); ByteArrayOutputStream bout = new ByteArrayOutputStream(512); byte[] buffer = new byte[2048]; int len = 0; while ((len = in.read(buffer)) > 0) { bout.write(buffer, 0, len); } in.close(); bout.close(); return bout.toString(CHARACTER_ENCODING_UTF_8); } }