如何在创建文本文件时添加新行

时间:2017-09-08 00:51:01

标签: java

我有一个问题,这里输出的文本文件每次都不会换行。我猜\ n是不是正确的用法?

    BufferedWriter out = new BufferedWriter(new FileWriter(id + ".txt"));
        out.write(" ID: "+ id);
        out.write("\n Name: "+ name);
        out.write("\n Date of Birth: "+ dateOfBirth);
        out.write("\n Address:"+ address);
        out.write("\n Phone Number: "+ phoneNumber);
        out.write("\n Licence Number: "+ licenceNumber);
        out.write("\n Age: "+ age);
        out.write("\n Licence Experation Date: "+ licenceExperationDate);

    out.close();

0 个答案:

没有答案