解决方案 »

  1.   

    读取流之前 选判断responseCode是否为200,如果为200再读取InputStream
      

  2.   


    读取之前会有其他代码判断是否是200
    其他类似的url都没出错,只有这一个出错,不知道是不是url里面有什么字符有问题?
      

  3.   

    问题是,我在程序里面没有做过什么过滤,只是中文部分做了个urlencode
      

  4.   

    public String encode(String str){
    try {
    str=URLEncoder.encode(str, "UTF-8");
    } catch (UnsupportedEncodingException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    return str;
    }
      

  5.   

    public InputStream getInputStreamFromUrl(String sUrl) throws MalformedURLException, IOException{
    url = new URL(sUrl);
    HttpURLConnection urlConn = (HttpURLConnection) url.openConnection();
    InputStream inputStream = urlConn.getInputStream();
    return inputStream;
    }
      

  6.   


    StringWriter writer = new StringWriter();
    IOUtils.copy(conn.getInputStream(), writer,"UTF-8");
    你这样试试。
      

  7.   

    问题解决了。。有个地方没有urlencode,sUrl字符串里有个空格