Here you can find the source of capitalizeAllWords(String text)
Parameter | Description |
---|---|
text | the original string |
public static String capitalizeAllWords(String text)
//package com.java2s; //License from project: Open Source License public class Main { /**/*from ww w .ja v a 2s . c o m*/ * Capitalizes all words in a string * @param text the original string * @return altered string */ public static String capitalizeAllWords(String text) { String[] Split = text.split("_"); String Out = ""; for (int i = 0; i < Split.length; i++) { Out += capitalize(Split[i]); if (i < Split.length) { Out += "_"; } } return Out; } /** * Capitalize on single word * @param word the word * @return capitalized word */ public static String capitalize(String word) { String FirstLetter = word.substring(0, 1); return FirstLetter.toUpperCase() + word.substring(1); } }