开发者

while loops and fileStreams

开发者 https://www.devze.com 2023-04-10 04:12 出处:网络
i have the code below: while (FileOne.hasNextLine()){ String check = FileOne.nextLine(); Reader r = new FileReader(\"something\");

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 (FileT开发者_开发百科wo.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)?


It should start from the beginning because you create a new scanner.

0

精彩评论

暂无评论...
验证码 换一张
取 消