๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #14450

Re: How to compare characters in Strings

#14450
From: blaszczykl
Date: Tue, 31 Aug 1999 00:00
40 lines
1751 bytes
  Well I tried the following and it STILL always returns true in the IF
statement:

String txt = "this\nthat";
String tmp = txt.substring(i,i+1); // the i is from a FOR loop
if ( tmp.equals(System.getProperty("line.separator")) )
  blah;

  I also tried:

if ( tmp == System.getProperty("line.separator") )
  blah;

  How do I use getProperty correctly?

In article <K0Qx3.13$D31.16780@news>,
  "Patrick Luginb๏ฟฝhl" <patrick.luginbuehl@switzerland.org> wrote:
>  Code like this:
>
> if (c == '\n')
>      fin = true;
> is not cross-platform. On Unix the line terminator is "\n", on
Windows, it
> is frequently "\r\n", on the Mac it is "\r".
>
> The call System.getProperty("line.separator") will return a string
> containing the platform-specific line separator character(s), and you
then
> need to compare it according to how your data is formatted (e.g.
compare 2
> characters or one).
>
> Good luck
> Patrick
>
>


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
Technical Details
Message-ID: <7qgk1u$i58$1@nnrp1.deja.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <7q1dkr$7sa$1@nnrp1.deja.com> <K0Qx3.13$D31.16780@news>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: f74b3,b2df74743a5cf7a0
X-Google-Attributes: gidf74b3,public
From: blaszczykl@my-deja.com
Subject: Re: How to compare characters in Strings
Date: 1999/08/31
Message-ID: <7qgk1u$i58$1@nnrp1.deja.com>
X-Deja-AN: 519277449
References: <7q1dkr$7sa$1@nnrp1.deja.com> <K0Qx3.13$D31.16780@news>
X-Http-Proxy: 1.1 x37.deja.com:80 (Squid/1.1.22) for client 144.174.137.126
Organization: Deja.com - Share what you know. Learn what you don't.
X-Article-Creation-Date: Tue Aug 31 13:07:20 1999 GMT
X-MyDeja-Info: XMYDJUIDblaszczykl
Newsgroups: borland.public.jbuilder.java.language
X-Http-User-Agent: Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)