user758084
user758084

Reputation: 35

while loops and fileStreams

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)?

Upvotes: 0

Views: 73

Answers (1)

Tobias
Tobias

Reputation: 9380

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

Upvotes: 1

Related Questions