Re: TitleCasing a String - [Perfect Solution]
Re: TitleCasing a String - [Perfect Solution]
- Subject: Re: TitleCasing a String - [Perfect Solution]
- From: "Jonathan Fleming" <email@hidden>
- Date: Tue, 06 Jan 2004 13:08:42 +0000
Thanks guys,
absolutely perfect.
Jonathan :^)
From: Geoff Hopson <email@hidden>
To: Alexander Spohr <email@hidden>
CC: Jonathan Fleming <email@hidden>,
email@hidden
Subject: Re: TitleCasing a String - probably a java question
Date: Tue, 6 Jan 2004 11:00:07 +0000
public static String capitalise(String oldStr) {
int len = oldStr.length();
if (oldStr == null || len == 0) {
return oldStr;
}
StringBuffer buff = new StringBuffer(len);
boolean white = true;
for (int i = 0; i < len; i++) {
char c = oldStr.charAt(i);
if (Character.isWhitespace(c)) {
buff.append(c);
white = true;
} else if (white) {
buff.append(Character.toTitleCase(c));
white = false;
} else {
buff.append(c);
}
}
return buff.toString();
}
_________________________________________________________________
Stay in touch with absent friends - get MSN Messenger
http://www.msn.co.uk/messenger
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.