搜索

首页  >  问答  >  正文

编码 - java下载xml文件解码问题

        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中文网2887 天前352

全部回复(1)我来回复

  • 天蓬老师

    天蓬老师2017-04-17 17:41:04

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

    回复
    0
  • 取消回复