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();
}

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 ( ) ; }
convert string to title case
