public static String capitalizeFirstOnly(String s){
  if (s == null)   return null;
  if (s.length() == 0)   return s;
  StringBuffer sbuf=new StringBuffer();
  char c=s.charAt(0);
  sbuf.append(Character.toUpperCase(c));
  boolean space=Character.isWhitespace(c);
  for (int i=1; i < s.length(); ++i) {
    c=s.charAt(i);
    if (Character.isWhitespace(c)) {
      space=true;
    }
 else     if (space) {
      c=Character.toUpperCase(c);
      space=false;
    }
 else {
      c=Character.toLowerCase(c);
    }
    sbuf.append(c);
  }
  return sbuf.toString();
}

public static String capitalizeFirstOnly ( String s ) { if ( s == null ) return null ; if ( s . length ( ) == 0 ) return s ; StringBuffer sbuf = new StringBuffer ( ) ; char c = s . charAt ( 0 ) ; sbuf . append ( Character . toUpperCase ( c ) ) ; boolean space = Character . isWhitespace ( c ) ; for ( int i = 1 ; i < s . length ( ) ; ++ i ) { c = s . charAt ( i ) ; if ( Character . isWhitespace ( c ) ) { space = true ; } else if ( space ) { c = Character . toUpperCase ( c ) ; space = false ; } else { c = Character . toLowerCase ( c ) ; } sbuf . append ( c ) ; } return sbuf . toString ( ) ; }
capitalize all letters preceded by whitespace , and lower case all other letters .
