java如何过两秒钟在.txt里读取一个数据啊
求代码
[解决办法]
用timer,
2秒读一次,
文件尾结束
[解决办法]
for example
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.csdn.net/cai5/article/details/7528888
看看这里的代码 ,不知道对你有没有用?