ok so my original code was:
Patient patient = new Patient();
patient.setId(1);
patient.setName("luke");
patient.setAddress("100 test");
patient.setTelNumber("01484710204");
patient.healthproblem.setBrainProblemName("Brain Cancer");
patient.healthproblem.setDateDiagnosed("30-03-1990");
patient.healthproblem.setPatientHealth("Poor");
Patient patient1 = new Patient();
patient1.setId(2);
patient1.setName("john");
patient1.setAddress("100 test");
patient1.setTelNumber("01484710204");
patient1.healthproblem.setLungProblemName("Lung Cancer");
patient1.healthproblem.setDateDiagnosed("12-02-1991");
patient1.healthproblem.setPatientHealth("Poor");
patient1.healthproblem.setLungProblemSide("Left");
if ("luke".equalsIgnoreCase(patient.getName())) {
out.writeObject(patient);
} else if ("john".equalsIgnoreCase(patient.getName())) {
out.writeObject(patient1);
}
so when the client typed ether luke or john it would return the data about them, now i have the patient data loading from a data file using the object outputsream to file. i created this to read in the object then return it:
public Object readPersons() throws IOException {
Patient patient = null;
try {
ObjectInputStream in = new ObjectInputStream(new FileInputStream("PatientData.data"));
for (int i = 0; i < 200; i++) {
patient = (Patient) in.readObject();
}
in.close();
} catch (ClassNotFoundException ex) {
Logger.getLogger(TestData.class.getName()).log(Level.SEVERE, null, ex);
} catch (EOFException eof) {
}
return patient;
}
but now the problem is what do i put where the write object is? and also how to loop round the file for the patients name :S
if ( ??? .equalsIgnoreCase(patient.getName())) {
out.writeObject( ??? );
}
thanks in advanced.
Houlahan