I have this code to write to a file. However, this only saves one entry.
How can I save multiple entries, each saved in separate lines ?
At this point the output in the .txt file is strange:
’ t Peter|t Pan|t 01/09/67|t 098 1456789|t 18-Mar-2009|t Male Surgical Wardt
I need the text to be clear in order to read it in a JTable
public void writeTable() {
try {
String ward = (String)wardCom bo.getSelectedI tem();
ObjectOutputStr eam file = new ObjectOutputStr eam
(new FileOutputStrea m("tablePat.txt "));
file.writeObjec t(name.getText( ) + "|");
file.writeObjec t(surname.getTe xt() + "|");
file.writeObjec t(dobInput.getT ext() + "|");
file.writeObjec t(emgInput.getT ext() + "|");
file.writeObjec t(dateInput.get Text() + "|");
file.writeObjec t(ward);
file.writeObjec t("\n");
file.close();
} catch (IOException ex) {
ex.printStackTr ace();
}
}
How can I save multiple entries, each saved in separate lines ?
At this point the output in the .txt file is strange:
’ t Peter|t Pan|t 01/09/67|t 098 1456789|t 18-Mar-2009|t Male Surgical Wardt
I need the text to be clear in order to read it in a JTable
public void writeTable() {
try {
String ward = (String)wardCom bo.getSelectedI tem();
ObjectOutputStr eam file = new ObjectOutputStr eam
(new FileOutputStrea m("tablePat.txt "));
file.writeObjec t(name.getText( ) + "|");
file.writeObjec t(surname.getTe xt() + "|");
file.writeObjec t(dobInput.getT ext() + "|");
file.writeObjec t(emgInput.getT ext() + "|");
file.writeObjec t(dateInput.get Text() + "|");
file.writeObjec t(ward);
file.writeObjec t("\n");
file.close();
} catch (IOException ex) {
ex.printStackTr ace();
}
}
Comment