I am trying to read the contents of a file:
Scanner fileReader = new Scanner("myFile.txt");
int counter = 0;
while(fileReader.hasNextLine()) {
if(counter == 0) {
System.out.println("IT IS READING " + fileReader.nextLine());
}
}
myFile.txt content:
HELLO WORLD
HELLO WORLD
Instead of printing hello world:
I am getting: IT IS READING myFile.txt