Sample Code to convert text to camel case using java

02 December 2017

public static String toTitleCase(String input) {
     StringBuilder titleCase = new       StringBuilder();
    boolean nextTitleCase = true;
    for (char c : input.toCharArray()) {
           if (Character.isSpaceChar(c)) { 
                  nextTitleCase = true;
           }
           else if (nextTitleCase) {
                    c = Character.toTitleCase(c);   
                    nextTitleCase = false;
           }
           titleCase.append(c);
     }
return titleCase.toString();
}

0 comments:

 
 
HTML Hit Counter