Не работает перенос строки - Java
Формулировка задачи:
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) { try{ File file = new File("list.txt"); FileWriter out = new FileWriter(file, true); try{ if(!file.exists()) file.createNewFile(); for(int x=0;x<2;x++){ for(int y=0;y<7;y++){ out.write(jTable2.getValueAt(x,y).toString()+ " "); } out.write("\n"); } } finally{ out.close(); } }catch(IOException e1){ throw new RuntimeException(e1); }
Решение задачи: «Не работает перенос строки»
textual
Листинг программы
File file = new File("d:/list.txt"); try (FileWriter out = new FileWriter(file, false)) { for (int x = 0; x < 2; x++) { for (int y = 0; y < 7; y++) { out.write(x + " " + y + " "); } out.write(System.lineSeparator()); } } catch (IOException e) { e.printStackTrace(); }