Thread overview | |||||
---|---|---|---|---|---|
|
January 13, 2009 How to append a new line to a File/FileConduit? | ||||
---|---|---|---|---|
| ||||
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 |
January 13, 2009 Re: How to append a new line to a File/FileConduit? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sam Hu | 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).
|
January 14, 2009 Re: How to append a new line to a File/FileConduit? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jarrett Billingsley | Thanks.It works now. Regards, Sam |
Copyright © 1999-2021 by the D Language Foundation