【发布时间】:2014-05-12 09:58:51
【问题描述】:
我有一个压缩和解压缩字节数组的类;
public class Compressor
{
public static byte[] compress(final byte[] input) throws IOException
{
try (ByteArrayOutputStream bout = new ByteArrayOutputStream();
GZIPOutputStream gzipper = new GZIPOutputStream(bout))
{
gzipper.write(input, 0, input.length);
gzipper.close();
return bout.toByteArray();
}
}
public static byte[] decompress(final byte[] input) throws IOException
{
try (ByteArrayInputStream bin = new ByteArrayInputStream(input);
GZIPInputStream gzipper = new GZIPInputStream(bin))
{
// Not sure where to go here
}
}
}
如何解压输入并返回字节数组?
注意:由于字符编码问题,我不想对字符串进行任何转换。
【问题讨论】:
标签: java compression gzip