More specifically, how could I write code that could create a scanner for any text file that the user enters? For instance, one user might want to scan text from “foo.txt,” and another might want to read from “bar.txt.” How do I compensate for this?
Share
You can simply make a function that opens a file and returns the reader so that you can read each line:
Then use the BufferedReader which it returns and iterate through each line! Hope it helps!