This is the mail archive of the
java-patches@sourceware.cygnus.com
mailing list for the Java project.
String.trim fix
- To: jewel at pixie dot co dot za
- Subject: String.trim fix
- From: "jewel at pixie dot co dot za" <jewel at pixie dot co dot za>
- Date: Mon, 15 May 2000 04:45:57 -0200 (GMT+2)
- Cc: java-patches at sourceware dot cygnus dot com, classpath at gnu dot org
I had problems with the String.trim() method, changing it from:
public String trim() {
if (count == 0 || (value[0] > '\u0020' && value[count-1] > '\u0020'))
return this;
int begin = 0;
for (; begin < count; begin++)
if (value[begin] > '\u0020')
break;
int end = count-1;
for (; end >= 0; end--)
if (value[end] > '\u0020')
break;
return substring(begin, end);
}
to
public String trim() {
if (count == 0 || (value[0] > '\u0020' && value[count-1] > '\u0020'))
return this;
int begin = 0;
for (; begin < count; begin++)
if (value[begin] > '\u0020')
break;
int end = count-1;
for (; end >= 0; end--)
if (value[end] > '\u0020')
break;
return substring(begin, end + 1);
}
helped.
Note I just added "+ 1" in the return line.
I haven't tested this thoroughly but it made my problems go away.
John Leuner