Finally solution found using the split() method of the String class (in addition to the Scanner class) as follows:
public static LinkedList<GymMembers> readFile() throws FileNotFoundException
{
LinkedList<GymMembers>gymMem= new LinkedList<GymMembers>();
Scanner input = new Scanner(new FileReader("Members.txt"));
try
{
//read line by line
while(input.hasNextLine())
{
String line = input.nextLine();
String[] split= line.split(" ");
String fName = split[0];
String lName = split[1];
double m_height = Double.parseDouble(split[2]);
int m_weight = Integer.parseInt(split[3]);
System.out.println( fName + " " + lName + " " + m_height + " " + m_weight);
gymMem.add(new GymMembers(fName, lName, m_height, m_weight));
}
System.out.println();
}catch( InputMismatchException e )
{
System.out.println("Invalid input entered.. please try again");
}
input.close();
return gymMem;
}
From the terminal:
Joan Smith 1.68 62
Mary Williams 1.65 78
Martin Jones 1.83 62
Henry Davies 1.92 145
Nigel Brown 1.78 50
I would like to thank you Norm and dlorde for their help.