検索

ホームページ  >  に質問  >  本文

编码 - 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日前359

全員に返信(1)返信します

  • 天蓬老师

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

    gzip と同様に、最初に解凍する必要があります
    リンクの説明

    返事
    0
  • キャンセル返事