【工具】html请求 Content-Encoding=br 返回值乱码的问题 解码返回值

【工具】Content-Encoding=br 解码返回值

添加依赖

        
            org.brotli
            dec
            0.1.2
        

代码

public static String 解码br(InputStream is) {
        try {
            BrotliInputStream stream = new BrotliInputStream(is);
            BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
            StringBuilder result = new StringBuilder();
            String str = null;
            while ((str = reader.readLine()) != null) {
                result.append(str);
            }
            return result.toString();
        } catch (IOException e) {
            e.printStackTrace();
            return null;
        } finally {
            IOUtils.closeQuietly(is);
        }
    }

你可能感兴趣的:(工具自用,java,开发语言)