Reading data from a text file into an object
Lets say I have several lines of data in a text file...ex...
Joe Stevens M 40 5
Maya Moore F 39 3
Bo Johnson M 25 4
I want to put all this data into a "payroll" object for later use. If it was just one line I would be done...
String line = in.readLine();
Payroll one = new Payroll(line);
any help appreciated
Re: Reading data from a text file into an object
Not sure at which step the problem is so if the following doesn't help please be more specific....to read the file line by line, just loop over the Stream until readLine returns null (which is the end of the file). If you are to create a new Payroll on a line-by-line basis, then add them to an array or a List for later use