Untitled
unknown
java
3 years ago
2.0 kB
6
Indexable
private void displayAppointmentList() throws FileNotFoundException, IOException { // return list of appointment with cust details BufferedReader brApp = new BufferedReader(new FileReader(appointmentTxtFile)); List<Appointment> appointmentList = new ArrayList<Appointment>(); BufferedReader brCust = new BufferedReader(new FileReader(custTxtFile)); List<Customer> custList = new ArrayList<Customer>(); //skip the first line String firstLine = brApp.readLine(); String firstLineCust = brCust.readLine(); //System.out.println(firstLine); Scanner sc = new Scanner(brApp); Scanner scCust = new Scanner(brCust); while (sc.hasNextLine() && scCust.hasNextLine()) { String dataLine = sc.nextLine(); String custDataLine = scCust.nextLine(); //System.out.println(dataLine); String data[] = dataLine.split(","); String custData[] = custDataLine.split(","); Appointment appointment = new Appointment(); appointment.setAppointmentID(Integer.valueOf(data[0])); appointment.setAppointmentFees(Integer.valueOf(data[1])); appointment.setAppointmentDate(data[2]); appointment.setAppointmentTime(data[3]); appointment.setAppointmentFeedback(data[4]); appointment.setAppointmentStatus(data[5]); Customer cust = new Customer(Integer.valueOf(custData[0]), custData[1], custData[2], custData[3]); custList.add(cust); appointmentList.add(appointment); } sc.close(); brApp.close(); AppointmentTableModel apptablemodel = new AppointmentTableModel(); //warning: the row number of appList must == row number of custList for the rowcount to display properly apptablemodel.setList(appointmentList, custList); AppointmentTable.setModel(apptablemodel); }
Editor is loading...