Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / April 2008

Tip: Looking for answers? Try searching our database.

simple help

Thread view: 
xinxin - 19 Apr 2008 14:44 GMT
String format="\n"+year+"年"+month+"月\n"+day+"日"+hour+"时"+min+"分"  + "
"+task;

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.
xinxin - 19 Apr 2008 14:55 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.
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.
Roedy Green - 19 Apr 2008 23:53 GMT
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



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.