[Advanced-java] Strings
Lance Eason
lance.eason at whisperwire.com
Tue Jul 1 14:25:40 2003
Looks like "name" has some whitespace on the end of it. Replace 'loc += name' with 'loc += name.trim()'
-----Original Message-----
From: Marco Ferretti [mailto:marco.ferretti@jrc.it]
Sent: Tuesday, July 01, 2003 7:53 AM
To: advanced-java@lists.xcf.berkeley.edu
Subject: [Advanced-java] Strings
Hi all guys... I have an xfile for you ...
Assume this code :
....
String loc = currPathLocation.toLowerCase();
String fs = System.getProperty("file.separator");
fs = ""+fs.charAt(0);
System.out.println("fs = " + fs);
System.out.println("loc = " + loc);
if(!loc.endsWith(fs)){
loc += fs;
System.out.println("loc + fs = " + loc);
}
loc +=name;
System.out.println("name = " + name);
System.out.println("loc + name = " + loc);
if (loc.indexOf(".") == -1) {
loc = loc + ".sid";
System.out.println("loc+ \".sid\" = " + loc);
}
....
How can this output come out ?
fs = \
loc = c:\tmp\sid\models
loc + fs = c:\tmp\sid\models\
name = F2HX
loc + name = c:\tmp\sid\models\F2HX
loc+ ".sid" = c:\tmp\sid\models\F2HX
.sid
I am using jdk 1.4.1_01 and Eclipse as gui on a windows xp plantform .
TIA
Marco
_______________________________________________
Advanced-java mailing list
Advanced-java@lists.xcf.berkeley.edu
http://lists.xcf.berkeley.edu/mailman/listinfo/advanced-java