String Hasil = TextHasil.getText();
try (PrintWriter out = new PrintWriter("C:/Users/steve/Desktop/HasilDekripsi.txt")) {
out.println(Hasil);
}catch (FileNotFoundException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
1:
答案 0 :(得分:1)
尝试替换换行符:
out.println(Hasil.replaceAll("\n","\n\n"));
OR
out.println(Hasil.replaceAll("\n","\r\n"));
您可以获得独立于平台的行分隔符:
System.getProperty("line.separator")
或
System.lineSeparator();