Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-13-2007, 09:50 PM
Member
 
Join Date: Jun 2007
Posts: 13
vissu007 is on a distinguished road
Please help me out here
consider the following program segment..

FileWriter f=new FileWriter(args[0]);
............
..........
f.write('\n');

The above given segment is from one of my programs.whenever I use f.write('\n') to go to a new line in the output file,the function is printing a small square box in the file.But,I want it to move the control to a new line so that whatever character it writes in the file thereafter writes it in a new line.This is happening for all the escape sequences used.Can anybody give me a solution for this problem?Reply soon.Thanq....
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-13-2007, 10:52 PM
JavaBean's Avatar
Moderator
 
Join Date: May 2007
Posts: 1,272
JavaBean is on a distinguished road
"\n" is not a platform independent way of writing a new line to a file. Try using:

Code:
f.write(System.getProperty("line.separator"));
Here are some relevant javadocs:

BufferedWriter.html#newLine()
System.html#getProperties()
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 07-14-2007, 01:55 PM
Member
 
Join Date: Jun 2007
Posts: 13
vissu007 is on a distinguished road
Thanks for the reply.What about using other escape sequences like '\b'(Whitespace)?
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 07-14-2007, 02:10 PM
JavaBean's Avatar
Moderator
 
Join Date: May 2007
Posts: 1,272
JavaBean is on a distinguished road
The problem is not escape sequences! They are same on all platforms. The problem is the new line for files! As far as i remember it was \r\n (Linux i guess) in one platform and \n (Windows i guess) in the other one.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +3. The time now is 10:14 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org