「Java入門」java.util.zip.GZIPInputStream()でファイルを展開する方法

Javaコード
public static byte[] deCompress(byte[] targetStr) {
if (targetStr == null || targetStr.length == 0) {
return null;
}
ByteArrayOutputStream out = new ByteArrayOutputStream();
ByteArrayInputStream in = new ByteArrayInputStream(bytes);
try {
GZIPInputStream cft = new GZIPInputStream(in);
byte[] buffer = new byte[256];
int n;
while ((n = cft.read(buffer)) >= 0) {
out.write(buffer, 0, n);
}
} catch (IOException e) {
log.error(e);
}

return out.toByteArray();
}

Java

Posted by arkgame