I have a text file formatted like this:
[Employee ID], [Full Name], [Rate of Pay]
A couple sample line looks like:
32483, William Ellis, 25.50
58411, Jonathan Ian Morris, 15.00
I'm trying to read all the employees in a text file and create objects of each one that will store the names, ID's, and wages in a hashmap. I'm taking EmpID as a string, the employee names as strings, and the wages as doubles. My problem is that it reads the EmpID's as a string including the "," then it will read the first name as the name variable, then attempt to take the middle or last name as a double with the "," also attached. So for instance it would come off as:
empID: "32483,"
fullName: "William"
wage: Ellis (which produces an error)
while(inputFile.hasNext()) {
empID = inputFile.next();
fullName = inputFile.next();
wage = inputFile.nextDouble();
empmap.put(empID, new Employee(empID, fullName, wage));
}
I figured I could try first and last name, but some have middle names or go by simply one name. I also considered the possibility of taking each character in character by character and concatenates them while using the "," as a sort of null character that lets the program know that everything that came before it is one string and a new string is about to begin but before I try something like that I figure there has to be an easier solution.