Re: New line in a JTextArea (student learning here)



Andrew Thompson wrote:
On Jan 30, 12:35 pm, Knute Johnson <nos...@xxxxxxxxxxxxxxxxxxxxxxx> wrote:
Andrew Thompson wrote:
On Jan 29, 11:12 am, Farcus Pottysqirt <where_is_my_...@xxxxxxxxxx>
wrote:
...
..Is the new-line
character represented differently on a different platform?
Sure is. Best to initilaise the line feed character as..
System.getProperty( "line.separator" );
...
Do you know an OS that uses a different line feed that runs Java?

AFAIU, JRE's on windows did historically return \n\r,
whereas *nix variatns use only \n.

OTOH, using System.getProperty("line.separator"),
is 'forward compatible' in the sense that if any new
OS architectures were to become support, or either
Win/*nix to suddenly change the line separator
(my bet would be Windows), the code would adapt.

Andrew T.


\n is a bad habit left over from my C days. I should probably watch that in the future :-).

--

Knute Johnson
email s/nospam/knute/
.



Relevant Pages