
October 11th, 2012, 03:53 PM
|
|
Registered User
|
|
Join Date: Oct 2012
Posts: 1
Time spent in forums: 15 m 12 sec
Reputation Power: 0
|
|
|
Been a while, help on code please.
Hey everyone. It has been a few years since I wrote code and I am trying to make a payroll program for my business. I came across some old GUI code I wrote a while back and having a brain fart!! This is the code I have and it works fine. My problem is now I have written my data to a .dat file but when I load the program I need it to read the information from the .dat file and load it correctly into the GUI. HELP! lol. Any assistance would be much appreciated!
if (button ==save)
{
FileWriter fstream;
try{
fstream = new FileWriter("C:\\data\\employee.dat");
}catch (Exception ex){//Catch exception if any
// Create one directory
(new File("C:\\data\\")).mkdir();
try{
fstream = new FileWriter("C:\\data\\employee.dat");
}
catch (Exception ex1){//Catch exception if any}
return;
}
}
BufferedWriter out = new BufferedWriter(fstream);
try{
out.write(""+total+"\n");
for(int i=0;i<total;i++)
{
Employee productObj = productArray[i];
if (productObj.getClass() == Overtime.class) {
out.write("Overt\n");
Overtime dcObj = (Overtime) (productObj);
out.write(""+dcObj.overtime()+"\n");
}
else
{
out.write("Old\n");
}
out.write(""+productObj.cspNumber()+"\n");
out.write(""+productObj.displayCsp()+"\n");
out.write(""+productObj.displayClient()+"\n");
out.write(""+productObj.rate()+"\n");
out.write(""+productObj.hoursWorked()+"\n");
}
out.close();
}
catch (Exception ex){//Catch exception if any
}
}
if (button == load)
{
?????????????????????
Output is as follows:
3
Old
761665
Steve Troxell
AT&T Mobility
0.0
0
Old
768277
Christina Fowler
AT&T KCA
0.0
0
Overt
0.0
697726
Debbie Troxell
Apple Chat
0.0
0
|