public static String makeInitCap(String name){
  int i;
  StringBuilder icap=new StringBuilder(name);
  int nlen=icap.length();
  boolean cap_flag=true;
  for (i=0; i < nlen; ++i) {
    char c=icap.charAt(i);
    if (Character.isLetterOrDigit(c)) {
      if (Character.isLowerCase(c)) {
        if (cap_flag)         icap.setCharAt(i,Character.toUpperCase(c));
      }
 else       if (Character.isUpperCase(c)) {
        if (!cap_flag)         icap.setCharAt(i,Character.toLowerCase(c));
      }
      cap_flag=false;
    }
 else {
      cap_flag=true;
    }
  }
  return (icap.toString());
}

public static String makeInitCap ( String name ) { int i ; StringBuilder icap = new StringBuilder ( name ) ; int nlen = icap . length ( ) ; boolean cap_flag = true ; for ( i = 0 ; i < nlen ; ++ i ) { char c = icap . charAt ( i ) ; if ( Character . isLetterOrDigit ( c ) ) { if ( Character . isLowerCase ( c ) ) { if ( cap_flag ) icap . setCharAt ( i , Character . toUpperCase ( c ) ) ; } else if ( Character . isUpperCase ( c ) ) { if ( ! cap_flag ) icap . setCharAt ( i , Character . toLowerCase ( c ) ) ; } cap_flag = false ; } else { cap_flag = true ; } } return ( icap . toString ( ) ) ; }
convert a string to init - cap format . this ensures that we can match http - style naming e . g . " accept - charset " .
