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 20:15:50 +0000
This is probably best, I'm sure I've got it right this time
Jonathan :^)
public static String capitalise(String oldStr) {
if (oldStr == null) return oldStr;
int len = oldStr.length();
if (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();
}
From: "Jonathan Fleming" <email@hidden>
To: email@hidden
CC: email@hidden, email@hidden
Subject: Re: TitleCasing a String - [Perfect Solution]
Date: Tue, 06 Jan 2004 20:01:39 +0000
OOPs, forgot to delete || len == 0
How's 'hat Alexander ?
Thanks
Jonathan :^)
public static String capitalise(String oldStr) {
if (oldStr == null) {
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
_________________________________________________________________
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.
_________________________________________________________________
It's fast, it's easy and it's free. Get MSN Messenger today!
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.