I'm kinda new to Java so I'm looking for an help to do this.
As the title says, I'm trying to write a program that checks if a number given by the user from console is inside a text file with one number for each line or not.
I am using the Scanner
class to check every line, but I am having problems with what condition the if statement should have when the number is found inside the file.
I wrote down this part code (I'm not even sure if it's correct itself, so correct me if I'm wrong):
int lines = 0;
while (filescanner.hasNextLine()) {
String line = filescanner.nextLine();
lines++;
if(conditon here) {
System.out.println("I found the number on line " + lines);
}
}
Thanks in advance.