Java. Need to read file twice
<p>I am new in programming world and now I am writing a simple code to read a text file which in each line stores student name and age. And for some reason I need to read that file twice, so I want to ask is there an easier way to do that than this?</p>

<pre><code>File inputFile = new File("students.txt");

try {
    Scanner in = new Scanner (inputFile);

    // count how many lines are in the file
    while (in.hasNext())
    {
        in.nextLine();
        count++;
    } 

    in.close();
} catch (FileNotFoundException e) {
    System.out.println ("Check your file mate");
}

ArrayStudent s = new ArrayStudent(count);

try {
    Scanner in2 = new Scanner (inputFile);

    while (in2.hasNext())
    {
        String name = in2.next();
        int age = in2.nextInt();
        s.insertStudent(new Student (name, age));
    } 

    in2.close();
} catch (FileNotFoundException e) {
    System.out.println ("Check your file mate");
}
</code></pre>
