java怎么过两秒钟在.txt里读取一个数据
java如何过两秒钟在.txt里读取一个数据啊
求代码
------解决方案--------------------
用timer,
2秒读一次,
文件尾结束
------解决方案--------------------
for example
求代码
------解决方案--------------------
用timer,
2秒读一次,
文件尾结束
------解决方案--------------------
for example
- Java code
final Scanner sc = new Scanner(new FileInputStream("filename")); Timer timer = new Timer(); timer.scheduleAtFixedRate(new TimerTask() { public void run() { try { if (sc.hasNext()) {System.out.println(sc.next());} } catch (Throwable e) {} } }, 0, 2000);
------解决方案--------------------
http://blog.****.net/cai5/article/details/7528888
看看这里的代码 ,不知道对你有没有用?