weixin_38478577
weixin_38478577
2017-12-07 07:54

InputStreamReader读取远程文件时出错

public static String readUrl(String urlString){
    StringBuffer urlBuf = new StringBuffer();
    try{
        URL url = new URL(urlString);
        BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream(),"utf-8"));
        String inputLine;
        while ((inputLine = in.readLine()) != null) {
            urlBuf.append(inputLine).append("\r\n"); 
            System.out.println(urlBuf);
            }
        in.close(); 
    }catch(Exception e){
        urlBuf = new StringBuffer(""); 
    } 
    return urlBuf.toString();
} 
url是一个域名/xxx/xx.jsp.返回的结果为"<script>window.location.jref=url</script>"  俩个服务器一个是正常的,一个是上面那样的。
想问一下有没有大神遇到过这个问题,帮忙解决一下,谢谢。
  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

1条回答