搜尋

首頁  >  問答  >  主體

编码 - 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 天前355

全部回覆(1)我來回復

  • 天蓬老师

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

    和 gzip一樣需要先解壓縮
    連結描述

    回覆
    0
  • 取消回覆