Skip to content

Instantly share code, notes, and snippets.

@hakanu
Last active August 29, 2015 14:04
Show Gist options
  • Save hakanu/1983bc4f373744ee8155 to your computer and use it in GitHub Desktop.
Save hakanu/1983bc4f373744ee8155 to your computer and use it in GitHub Desktop.
Java Capitalize a sentence with multiple words (especially for Turkish)
public static String capitalize(String line) {
String[] words = line.split(" ");
StringBuilder sb = new StringBuilder();
for(String word: words) {
sb.append(Character.toUpperCase(word.charAt(0)));
sb.append(word.substring(1).toLowerCase(new Locale("tr", "TR")));
sb.append(" ");
}
return sb.toString();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment