使FileReader循环读取第四行 [英] Make FileReader read every fourth line with a loop
本文介绍了使FileReader循环读取第四行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的问题是,我在寻找客户时必须安排while循环以仅检查每四行读取的内容.
My problems is that I have to arrange, when searching for a customer, arrange the while loop to only examine every fourth line read.
这是我已经解决此问题的代码:
This is the code I already have on this problem:
BufferedReader br = new BufferedReader(new FileReader("Customers.txt"));
String line;
while ((line = br.readLine()) != null)
{
...
}
br.close();
有人知道在"..."处需要什么吗?
Does anybody know what needs to be at the place of "..."?
谢谢!
推荐答案
只需在循环结束时调用br.readLine()3次,并丢弃输出:
Just call br.readLine() 3 times at the end of the loop, discarding the output:
BufferedReader br = new BufferedReader(new FileReader("Customers.txt"));
String line;
while ((line = br.readLine()) != null)
{
...
for(int i=0;i<3;i++){ br.readLine(); }
}
br.close();
这篇关于使FileReader循环读取第四行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文