I will try to be as clear as possible, but I apologize if my question is not perfect. I have a txt file with several lines of data. Example:
123 ralph bose 20,000 200 1 2
256 ed shane 30,000 100 2 4
...
I need to read each line sequentially and pass it to the method in a separate class for processing. I know how to split each line into elements using StringTokenizer.
However, I'm not sure how to read one line at a time, pass the elements to another class, and then, as soon as the processing is complete, read the NEXT line. The collaboration method between my classes works fine (verified), but how can I read one line at a time?
I was thinking of creating an array where each row will be an element of the array, but as the number of rows is unknown, I cannot create an array because I do not know its final length.
thank
Woman
EDIT
rough setting:
Class A
end_of_file = f1.readRecord(emp);
if(!end_of_file)
{
slip.printPay(slipWrite);
}
Class B
public boolean readRecord(Employee pers) throws IOException {
boolean eof = false ;
String line = in.readLine() ;
???
}
the file name is never transferred
so until I can read the first line, but I think I need a way to scroll through the lines to read them one by one between the classes.
complicated...
source
share