This may not be the most effective, but it may give you a starting point:
public String capitalize(String original) {
String[] parts = original.split(" ");
StringBuffer result = new StringBuffer();
for (String part : parts) {
String firstChar = part.substring(0, 1).toUpperCase();
result.append(firstChar + part.substring(1));
result.append(" ");
}
String capitalized = result.toString();
return capitalized.substring(0, capitalized.length()-1);
}
source
share