How to put Enter key character (!_NEWLINE_!) in text file (Urgent)
1 posts in topic
Flat View  Flat View

Posted By:   Usman_Ali
Posted On:   Saturday, September 1, 2001 09:55 AM

i am storing different Tele phone nos in text file.
i want to store each no. on next line.
how i move my file pointer to next line or put enter key often

Re: How to put Enter key character (!_NEWLINE_!) in text file (Urgent)

Posted By:   hacene_khellaf  
Posted On:   Monday, September 10, 2001 03:21 AM

hi Ali,

you have to solutions for your question, either you use a primitive
FileOutputStream, and the to each line you add at the end the "
" character like in the following :

FileOutputStream fos = new
FileOutputStream("your file name ");

fos.write(("your text"+"

you do this for each line.

or just to wrap your FileOutputStream in a writer like PrintWriter since you are storing only text, or a PrintStream.

the 2 last classes have the println method which do the job for you

and you don't have to worry about "
" character :

examples :

PrintWriter pw = new PrintWriter(new FileOutputStream("your file"));

pw.println("your text");


hope it helps

About | Sitemap | Contact