?
Solved

How to put Enter key character (\n) in text file (Urgent)

Posted on 2001-09-01
6
Medium Priority
?
213 Views
Last Modified: 2008-03-06
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 \n.

Regards,

Macha
0
Comment
Question by:macha060500
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 19

Accepted Solution

by:
Jim Cakalic earned 120 total points
ID: 6448020
If using a FileWriter, you can write a newline character directly a in:

    FileWriter out = ...
    out.write("\n");

It would better, though, to use the platform-specific line separator sequence. You can get this from System properties:

    String sep = System.getProperty("line.separator");
    out.write(sep);

If you wrap your FileWriter with a BufferedWriter -- which is a good performance idea anyway -- then you can use the BufferedWriter's newLine method which does the above.

    FileWriter fw = ...
    BufferedWriter out = new BufferedWriter(fw);
    out.newLine();

Best regards,
Jim Cakalic
0
 
LVL 92

Expert Comment

by:objects
ID: 6448376
Use a PrintWriter to print to your file and use the method println() which inserts a platform independant newline.
0
 
LVL 5

Expert Comment

by:vemul
ID: 7773232
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

- split points between jim_cakalic and objects

Please leave any comments here within the
next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !

vemul
Cleanup Volunteer
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 19

Expert Comment

by:Jim Cakalic
ID: 7773261
OK.
0
 

Expert Comment

by:SpideyMod
ID: 7861447
Answered by jim_cakalic (first in with answer and points too low for split)

SpideyMod
Community Support Moderator @Experts Exchange
0
 
LVL 19

Expert Comment

by:Jim Cakalic
ID: 7870177
Thanks. :-)
0

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
This video teaches viewers about errors in exception handling.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses
Course of the Month12 days, 2 hours left to enroll

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question