首页 > java下载xml文件解码问题

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要怎么解码然后再输出到文件?


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

【热门文章】
【热门文章】