编码 - java下载xml文件解码问题
PHP中文网
PHP中文网 2017-04-17 17:39:04
0
1
347
        URL url = new URL(xmlURL);
        URLConnection uc = url.openConnection();
        String encoding = uc.getContentEncoding();
        InputStream is = uc.getInputStream();
//        byte[] data = null;
//        data = new byte[is.available()];
//        is.read(data);
        
        // 写入文件
         FileOutputStream out = new FileOutputStream(file);
        int i = 0;
        while ((i = is.read()) != -1) {
            out.write(i);
        }

直接输出为xml文件为乱码,encoding的值为:deflate;
问:deflate要怎么解码然后再输出到文件?

PHP中文网
PHP中文网

认证0级讲师

Antworte allen(1)
Peter_Zhu

和 gzip一样需要先解压缩
链接描述

Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage