File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Writing into a file without printing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Writing into a file without printing "\n" in seperate lines" Watch "Writing into a file without printing "\n" in seperate lines" New topic
Author

Writing into a file without printing "\n" in seperate lines

Monish Das
Greenhorn

Joined: Sep 28, 2006
Posts: 4
Hello Friends,
I am facing an issue that while writing to the file i am able to print "\n" for getting all the files in seperate line.But i want to avoid this i.e. i want to write in separate line but "\n" shouldnt be printed.
I am using bf.newLine() for the separate lines...
How can i avoid this?
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14146
    
  18

I don't know what you mean by "bf.newLine()". Is "bf" a variable in your program? If so, what's the type?

Different operating systems use different sequences of characters to represent newlines in text files. For example, Windows uses a sequence of two characters: carriage return and line feed (ASCII codes 10 and 13). Unix computers use just one character: line feed.

In Java, if you want to write a program that uses the line ending sequence of the operating system you're running it on, you should get the system property named "line.separator" instead of directly putting codes line "\n" in the program.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Writing into a file without printing "\n" in seperate lines