digitalmars.D.learn - How to append a new line to a File/FileConduit?
- Sam Hu (15/15) Jan 12 2009 Hello everyone!
- Jarrett Billingsley (5/15) Jan 13 2009 If you're on Windows, the line ending convention is "\r\n", not just
- Sam Hu (3/3) Jan 13 2009 Thanks.It works now.
Hello everyone! Just found I can not append a new line to a file when writing data to a File or FileConduit instance. File file=new File("myfile.txt"); myfile.append("This is line 1"); myfile.append("This is line 2"); About code just generate "This is line 1This is line 2" I tried below code but all the same: myfile.append("\n\nThis is line 1\n\n"); myfile.append("\n"); myfile.append("This is line 2"); Can anybody help my on how to make it ?I just want to write data into a file line by line: This is line 1 This is line 2 Thanks. Sam
Jan 12 2009
On Tue, Jan 13, 2009 at 1:42 AM, Sam Hu <samhu.samhu gmail.com> wrote:Hello everyone! Just found I can not append a new line to a file when writing data to a File or FileConduit instance. File file=new File("myfile.txt"); myfile.append("This is line 1"); myfile.append("This is line 2"); About code just generate "This is line 1This is line 2" I tried below code but all the same: myfile.append("\n\nThis is line 1\n\n"); myfile.append("\n"); myfile.append("This is line 2");If you're on Windows, the line ending convention is "\r\n", not just "\n", so you could try that. Alternatively, use a Print/FormatOutput (depends on whether you're using 0.99.7 or HEAD).
Jan 13 2009