I have a text file that looks like this
BEG#Belgrave#19 February 1962
FSS#Flinders Street#12 September 1854
TSN#Tecoma#1 February 1924
im trying to write a program, asking the user to input the filename (i can do this part), then the user is prompted to enter in a "Code". The program is then to read the txt file, and output information according the the unique code. for example:
java Codes
Enter file name >> stationsMaster.txt
Enter station code >> FSS
Station name: "Flinders" has code "FSS" date built: 12 September 1854
here is the code of what i have done so far, im just really stuck on how to write the code so that the program reads through the text file and outputs the according information from the user input.
import java.util.*;
import java.io.*;
public class Codes
{
public static void main (String [] args) throws IOException
{
Scanner keyboard = new Scanner (System.in);
System.out.print("Enter File Name");
String filename = keyboard.nextLine();
File f = new File (filename);
Scanner fin = new Scanner (f);
String stationcode = fin.nextLine();
String stationname = fin.nextLine();
String date = fin.nextLine ();
while (fin.hasNextLine ( ) )
{
System.out.print (date);
System.out.print(stationname);
}
fin.close ();
}