日期:2014-05-20 浏览次数:20791 次
public static String getURLContent(String urlString, String encoding) { if (urlString == null || "".equals(urlString.trim())) return null; StringBuffer content = new StringBuffer(); try { // 新建URL对象 URL url = new URL(urlString); InputStream in = new BufferedInputStream(url.openStream()); InputStreamReader theHTML = new InputStreamReader(in, encoding != null ? encoding : "gb2312"); int c; while ((c = theHTML.read()) != -1) { content.append((char) c); } } // 处理异常 catch (MalformedURLException e) { System.err.println(e); } catch (IOException e) { System.err.println(e); } return content.toString(); }
------解决方案--------------------
缓存的原因了
url后面拼一个 ?math.random()试一下
------解决方案--------------------
可能是缓存问题,后加随机数或者时间
祝楼主好运
------解决方案--------------------