> String format="\n"+year+"年"+month+"月\n"+day+"日"+hour+"时"+min+"分" + "
> "+task;
[quoted text clipped - 4 lines]
> writer.write(format);//I expect this words appear in newline in my
> //file but I am frustrated .who can tell me why .thanks in advance.
Alex.From.Ohio.Java@gmail.com - 19 Apr 2008 15:03 GMT
> > String format="\n"+year+"年"+month+"月\n"+day+"日"+hour+"时"+min+"分" + "
> > "+task;
[quoted text clipped - 4 lines]
> > writer.write(format);//I expect this words appear in newline in my
> > //file but I am frustrated .who can tell me why .thanks in advance.
They should be new lines.
Since you use Writer they are localized to your local system.
It's possible that you read in tool which is set for another
localization. Simplest example would be if you write file for UNIX
system and try to read it in Windows. Or Mac vs UNIX or whatever.
Look inside your file character by character and you should understand
what's going on.
Alex.
http://www.myjavaserver.com/~alexfromohio/
Jeff Higgins - 19 Apr 2008 15:16 GMT
> String format="\n"+year+"Äê"+month+"ÔÂ\n"+day+"ÈÕ"+hour+"ʱ"+min+"·Ö" +
> "
> "+task;
PrintWriter writer =
new PrintWriter(new BufferedWriter(new FileWriter(taskFile, true)));
writer.println(format);
Mark Space - 19 Apr 2008 21:47 GMT
>> String format="\n"+year+"年"+month+"月\n"+day+"日"+hour+"时"+min+"分" + "
>> "+task;
[quoted text clipped - 6 lines]
>
>>
Well, you haven't show us any newlines here. Does "task" have one? If
not then you have to add one.
Jeff had the best answer, use println from the PrintWriter class.
If you cannot for some reason, then you'll have to add the newlines
manually. Use System.getProperty("line.separator") to get the correct
newline for your system in that case.
On Sat, 19 Apr 2008 06:44:24 -0700 (PDT), xinxin
<jnzhouxinxin@gmail.com> wrote, quoted or indirectly quoted someone
who said :
> FileWriter writer = new FileWriter(taskFile, true);
>
> writer.write(format);
> writer.write(format);//I expect this words appear in newline in my
>file but I am frustrated who can
> // tell me why .thanks in advance.
see http://mindprod.com/applet/fileio.html
to generate you some code. You will need a PrintWriter.println() to
get the newlines right for your platform.

Signature
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
xinxin - 20 Apr 2008 05:55 GMT
On 4月20日, 上午6时53分, Roedy Green <see_webs...@mindprod.com.invalid>
wrote:
> On Sat, 19 Apr 2008 06:44:24 -0700 (PDT),xinxin
> <jnzhouxin...@gmail.com> wrote, quoted or indirectly quoted someone
[quoted text clipped - 15 lines]
> Roedy Green Canadian Mind Products
> The Java Glossaryhttp://mindprod.com
you are so great. I fell so great . i use
System.setProperty("line.separator","\r\n");and it works .thank you
very mush.
Roedy Green - 28 Apr 2008 05:58 GMT
On Sat, 19 Apr 2008 21:55:39 -0700 (PDT), xinxin
<jnzhouxinxin@gmail.com> wrote, quoted or indirectly quoted someone
who said :
>you are so great. I fell so great . i use
>System.setProperty("line.separator","\r\n");and it works .thank you
>very mush.
You don't need to do that. The line.separator property is already set
for you to the platform default.

Signature
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com