while 循环和文件流
我有下面的代码:
while (FileOne.hasNextLine()){
String check = FileOne.nextLine();
Reader r = new FileReader("something");
mass1:
try{
Scanner FileTwo = new Scanner(r);
mass1:
while (FileTwo.hasNextLine()) {
String toCheck= FileTwo.nextLine().toString();
index1 = check.indexOf(toCheck);
if(index1 != -1){
index2++;
break mass1;
}//if(index1 != -1)
}//(it.hasNext())
}//try
finally {
r.close();
}//finally
}//while (FileOne.hasNextLine())
我想问: 当第二个 while 又名 while (FileTwo.hasNextLine) 结束时(有或没有中断命令),解析器下次转到该命令时,文件将从开头开始还是从上次的位置开始? 如果它不是从头开始那么我将如何让它从它开始(开始)?
i have the code below:
while (FileOne.hasNextLine()){
String check = FileOne.nextLine();
Reader r = new FileReader("something");
mass1:
try{
Scanner FileTwo = new Scanner(r);
mass1:
while (FileTwo.hasNextLine()) {
String toCheck= FileTwo.nextLine().toString();
index1 = check.indexOf(toCheck);
if(index1 != -1){
index2++;
break mass1;
}//if(index1 != -1)
}//(it.hasNext())
}//try
finally {
r.close();
}//finally
}//while (FileOne.hasNextLine())
And i want to ask:
When the second while aka while (FileTwo.hasNextLine) ends (with or without the break command), the next time that the parser will go to that command, the file will start from the beggining or from the possition it was last time?
If it doesnt starts from the beggining then how will i make it to start from it (the beggining)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它应该从头开始,因为您创建了一个新的扫描仪。
It should start from the beginning because you create a new scanner.