在stackoverflow问了没人鸟我。。。
How to use zlib gzip a string in nodejs?
The result is difference between using GZIPOutputStream in java and using zlib.gzipSync() in nodejs zlib module;
the js code :
var endata = zlib.gzipSync(stringData);
the java code :
public static byte[] gzipData(String data) throws Exception {
byte[] b = null;
if (!StringUtils.isEmpty(data)) {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
GZIPOutputStream gzip = new GZIPOutputStream(bos);
gzip.write(data.getBytes());
gzip.finish();
gzip.close();
b = bos.toByteArray();
bos.close();
}
return b;
}
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
业精于勤,荒于嬉;行成于思,毁于随。