我正在尝试解码收到的字符串。它使用这里的 deflater 进行压缩: https: //github.com/dankogai/js-deflate 然后进行 base64 编码。
但是,当我使用 java inflater 时,我收到以下错误消息:未知的压缩方法。
import sun.misc.BASE64Decoder;
public void org() throws Exception{
BASE64Decoder decoder = new BASE64Decoder();
try {
String inputString = "84VWAVDY";
byte[] decodedByteArray = decoder.decodeBuffer(inputString);
// Decompress the bytes
Inflater decompresser = new Inflater();
decompresser.setInput(decodedByteArray);
byte[] result = new byte[100];
int resultLength = decompresser.inflate(result);
decompresser.end();
// Decode the bytes into a String
String outputString = new String(result, 0, resultLength);
System.out.println("OUTPUT:" + outputString);
} catch (Exception e){
System.out.println("Exception: " + e);
} …Run Code Online (Sandbox Code Playgroud)