public static String initCap(String in){
  if (in == null || in.length() == 0)   return in;
  boolean capitalize=true;
  char[] data=in.toCharArray();
  for (int i=0; i < data.length; i++) {
    if (data[i] == ' ' || Character.isWhitespace(data[i]))     capitalize=true;
 else     if (capitalize) {
      data[i]=Character.toUpperCase(data[i]);
      capitalize=false;
    }
 else     data[i]=Character.toLowerCase(data[i]);
  }
  return new String(data);
}

public static String initCap ( String in ) { if ( in == null || in . length ( ) == 0 ) return in ; boolean capitalize = true ; char [ ] data = in . toCharArray ( ) ; for ( int i = 0 ; i < data . length ; i ++ ) { if ( data [ i ] == ' ' || Character . isWhitespace ( data [ i ] ) ) capitalize = true ; else if ( capitalize ) { data [ i ] = Character . toUpperCase ( data [ i ] ) ; capitalize = false ; } else data [ i ] = Character . toLowerCase ( data [ i ] ) ; } return new String ( data ) ; }
init cap words with spaces
