I'm trying to figure out a way to print out specific Strings from a .txt file.
Here is my method:
public static void writeBirdtype() {
In innSkjerm = new In(); // Reading from terminal
In fil = new In("fugler.txt"); // Reading from file
System.out.println("Write out all the observations of a birdtype: ");
String ord = innSkjerm.readLine();
System.out.println("All the observations you asked for:");
while (fil.hasNext()) {
String linje = fil.inWord();
System.out.println(linje);
} // end of while-statement
} // end of writeBirdType() method
The problem is this code prints out all the Strings from a .txt file, which is not what i'm trying to accomplish. Can anyone see what I am missing here? Thank you.