Scanning a txt file with Java?
I know how to read a txt file in Java but what I dont know how to do is scan a txt file in java based on a starting value a user gives me.
For example: Say I have a txt file with a list from 1-20. ANd after each of those numbers is a answer to a math problem. Sure I can read it normally but how do I go about getting everything after that one number the user gave me? I just made this up below but you should get the idea.
A user inputs the number 1
The program scans the txt file for the first 1 that appears
The program then outputs the rest of the line after 1.
Re: Scanning a txt file with Java?
Performing IO is expensive (resource wise). So you want to read the text file once and store all the data in a Collection. Afterwards you can search/sort your data which is much simpler.