-
Scanner help
I need a scanner to go through a file an see if it contains a certain string. Is there a method that I can use or am I out of luck? I essentially need a contains method but for the scanner and after looking through the java docs I can't seem to find one. any ideas?
-
Re: Scanner help
Read the lines of the file into a List, and then check whether the List contains the String. Or just check each line as it's read in.
-
Re: Scanner help
Thanks! I added a while loop for while the file has another line. Then in that is an if statement where if the string is the next string in the file, it does what it's supposed to. Otherwise it goes to the next line. If there isn't another line then it tells you that the item doesn't exist. Thanks a ton
-
Re: Scanner help
Sounds really reasonable to me. Glad you got it sorted out.