[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: newline character problems



The System.getProperty("line.separator") will insert the line separator which
is appropriate for the platform on which the Java program is run.  In
particular:

    Windows and OS/2 - \r\n
    Unix - \n
    Mac - \r

So, based on what you said, the mainframe must expect the CR-LF
combination.    However, if you send your file to a Unix computer, then you
will see nasty ^M's from the extraneous "\r".  So the
System.getProperty("line.separator") is not a general solution unless you
actually run the Java program on the same or similar platform to that on
which the file will be used.

Cindy

Deron Pardue wrote:

> That did it.  Thanks!
>
> ----- Original Message -----
> From: "Lance England" <lengland@gr.com>
> To: <ajug-members@www.ajug.org>
> Sent: Monday, September 17, 2001 12:34 PM
> Subject: RE: newline character problems
>
> > You need to use System.getProperty("line.separator") in place of any \n
> > escape sequence.
> >
> > Example:
> >
> > out.print("This is line 1." + System.getProperty("line.separator") +
> > "This is line 2.");
> >
> > Regards,
> > Lance England
> > Greenbrier & Russel
> >
> > -----Original Message-----
> > From: Deron Pardue
> > Sent: Mon 9/17/2001 11:14 AM
> > To: ajug-members@www.ajug.org
> > Cc:
> > Subject: newline character problems
> >
> >
> > I'm writing a text file via a java program.  I'm using \n for
> > newlines.  If I open the file with WordPad or TextPad, the file is fine;
> > however, in notepad, the newline character is unrecognized (showing up
> > as that nasty little box that I hat so  much)  I've tried using \r also
> > and have the same problem.  This file is ultimately being used on a
> > mainframe which is reading it the same as notepad.
> >
> > Thanks!
> >
> > Deron
> >