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 18:53:38 +0000
How's 'hat Alexander ?
Thanks
Jonathan :^)
public static String capitalise(String oldStr) {
if (oldStr == null || len == 0) {
return oldStr;
}
int len = oldStr.length();
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();
}
From: Alexander Spohr <email@hidden>
To: "Jonathan Fleming" <email@hidden>
Subject: Re: TitleCasing a String - [Perfect Solution]
Date: Tue, 6 Jan 2004 15:37:27 +0100
that's the non-working version :)
atze
Am 06.01.2004 um 14:08 schrieb Jonathan Fleming:
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
_________________________________________________________________
Tired of 56k? Get a FREE BT Broadband connection
http://www.msn.co.uk/specials/btbroadband
_______________________________________________
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.