我要不断读取某个文件,第一次读取下来是正确的,当我要读取的文件中的值改变时,结果还是第一次读取的结果,不知是什么原因,那位大侠来帮一下啊
------解决方案--------------------
流及时关闭了么?
------解决方案--------------------
- Java code
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()试一下
------解决方案--------------------
可能是缓存问题,后加随机数或者时间
祝楼主好运
------解决方案--------------------
------解决方案--------------------
------解决方案--------------------
典型的线程问题,Buffer读取缓冲区,值变了缓冲内容没变。
刷新浏览器
------解决方案--------------------
我也想知道这个问题
------解决方案--------------------
缓存了。。。。