您的位置:首页 > 其它

通过流读取本地文件增加的内容

2012-04-21 22:10 169 查看
//通过这个方法可以读取本地文件增加的内容

File file = new File("d:/hello111.txt");

long count = 0;

BufferedReader in = null;

while(true){

 if(file.length() > count){

  in = new BufferedReader(new InputStreamReader(new FileInputStream(file)));

  in.skip(count);

  

  String lineString = "";

  do {

   lineString = in.readLine();

   System.out.println(lineString);

  } while (lineString != null);

  count = file.length();

  

  Thread.sleep(1000);

 }

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  file string null
相关文章推荐