• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

new lines in unix/windows

 
Joe Busch
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?

Thanks,
Joe
 
Joe Ess
Bartender
Posts: 9318
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
They're different on both systems. Different on a Mac too. Check out this this topic 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).
 
Connie Kamrowski
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you determine which system it is being opened by you could declare a public static final variable such as:

static final public String 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic