public static void filewrite(string str, String ResultfilePath) throws IOException{ try { // 打开一个写文件器,构造函数中的第二个参数true表示以追加形式写文件 FileWriter writer = new FileWriter(ResultfilePath, true); writer.write(str+System.getProperty("line.separator")); writer.close(); } catch (IOException e) { e.printStackTrace(); } }
使用java中的转义符“\r\n”
比较方便的用法是System.getProperty(“line.separator”)。