public void execute(Client client1){ TableBuilder tbuilder = new TableBuilder(); FileWriter fwriter; BufferedWriter bwriter; PrintWriter pwriter; String columnString; String dataString; File destFile = new File("result.csv"); try{ fwriter = new FileWriter(destFile); bwriter = new BufferedWriter(fwriter); pwriter = new PrintWriter(bwriter); int temp = client1.resultTable.getModel().getColumnCount(); int tempRow = client1.resultTable.getModel().getRowCount(); for (int i=0; i<temp; i++){ String colName = client1.resultTable.getColumnName(i); pwriter.print(colName); pwriter.print(";"); } int j=0; while(j<tempRow){ for (int i=0; i<temp; i++){ String data = client1.resultTable.getValueAt(j, i).toString(); pwriter.print(data); pwriter.print(";"); } j++; } bwriter.close(); } catch(Exception e){ System.out.println(e); }}}