// 壓縮
public static void makeZip(byte[] bytes) {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ZipOutputStream zout = new ZipOutputStream(bos);
try {
zout.write(bytes);
} catch (IOException e) {
logger.error(e);
} finally {
try {
bos.close();
zout.close();
} catch (IOException e) {
logger.error(e);
}
}
}
public static void getZip(byte[] bytes) {
ByteArrayInputStream in = new ByteArrayInputStream(bytes);
ZipInputStream zin = new ZipInputStream(in);
ByteArrayOutputStream out = new ByteArrayOutputStream();
try {
zin.getNextEntry();
} catch (IOException e) {
logger.error(e);
}
byte[] buffer = new byte[bytes.length];
int offset = -1;
try {
while ((offset = zin.read(buffer)) != -1) {
out.write(buffer, 0, offset);
}
} catch (IOException e) {
logger.error(e);
} finally {
try {
in.close();
zin.close();
out.close();
} catch (IOException e) {
logger.error(e);
}
}
}