public void getEmployeePrintWriter( List<PaySlipModel> emplist, String filePath, String reportType) { PaySlip_Earn_Deduction_Model model = new PaySlip_Earn_Deduction_Model(); try { PrintWriter pw = null; File file = new File(filePath); try { pw = new PrintWriter(new BufferedWriter(new FileWriter(file, true))); } catch (IOException ex) { ex.printStackTrace(); } PaySlipModel psm = null; Iterator itr = emplist.iterator(); if ("DBF".equalsIgnoreCase(reportType)) { while (itr.hasNext()) { psm = (PaySlipModel) itr.next(); pw.printf( "%-7s%-3s%-3s%-35s%-4s%-10s%-14s", psm.getEmpno(), psm.getRegion(), psm.getSectioncode(), psm.getEmployeename(), psm.getDesignation(), psm.getEpf(), psm.getBankaccountno()); pw.println(); } } else { while (itr.hasNext()) { psm = (PaySlipModel) itr.next(); pw.printf( "%-37s", psm.getRegion() + "," + psm.getEpf() + "," + psm.getEmployeename() + "," + psm.getDesignation() + "," + psm.getSectionname() + "," + psm.getBankaccountno() + "," + psm.getPaymentmode() + "," + psm.getPayscale()); pw.println(); } } pw.flush(); pw.close(); } catch (Exception ex) { ex.printStackTrace(); } }