자바 애플리케이션에서 nodejs를 통해 압축 된 데이터를 웹 페이지로 보냅니다. 데이터는 java deflater 및 base64 인코딩으로 압축됩니다. 웹 페이지에서 데이터를 https://github.com/dankogai/js-deflate (으)로 팽창하려하지만 작동하지 않습니다 (빈 결과). 내가 놓친 게 있니?Java에서 압축 - 자바 스크립트로 인한 팽창
자바 측 :
private String compress(String s) {
DeflaterOutputStream def = null;
String compressed = null;
try {
ByteArrayOutputStream out = new ByteArrayOutputStream();
// create deflater without header
def = new DeflaterOutputStream(out, new Deflater(Deflater.DEFAULT_COMPRESSION, true));
def.write(s.getBytes());
def.close();
compressed = Base64.encodeBase64String(out.toByteArray());
System.out.println(compressed);
} catch(Exception e) {
Log.c(TAG, "could not compress data: " + e);
}
return compressed;
}
자바 스크립트 측 :
var data = RawDeflate.inflate(Base64.fromBase64(compressed));
JSInflate와 잘 어울립니다. – ndsc