File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
The Java EE 7 Tutorial Volume 1 or Volume 2
this week in the
jQuery UI in Action
Java in General
new lines in unix/windows
Joined: Jan 07, 2005
Mar 02, 2005 15:22:00
How can I write a carriage return and line feed to an ascii file such that it will be properly recognized on both unix and windows operating systems?
Joined: Oct 29, 2001
Mar 02, 2005 17:47:00
They're different on both systems. Different on a Mac too. Check out this
for the platform-independent way to code, and avoid using applications that don't recognize other system's EOL markers (I'm looking at you, Windows Notepad).
"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
How To Ask Questions On JavaRanch
Joined: Aug 15, 2004
Mar 02, 2005 18:01:00
If you determine which system it is being opened by you could declare a public static final variable such as:
static final public
WINDOWS_EOL = "\r\n";
static final public String UNIX_EOL = "\n";
and then substitute these variables for the CHAR(10) or such commands at the line ends.
**How much deeper would the ocean be if Sponges didn't grow in it?**
It is sorta covered in the
JavaRanch Style Guide
subject: new lines in unix/windows
Converting shell script to a batch file
Automating a process
How to start Tomcat?
Ports used by the application
using Runtime.exec() and the process exitValue = 1
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014