Convert A String To Title Case

Home
// Convert The String To Title Case:
public String toTitleCase( String inStr )
{
  // Build a list of all the letters in the string:
  List letterList = new ArrayList();
  for ( int i = 0; i < inStr.length(); i++ ) {
    letterList.add(inStr.substring(i,(i+1)));
  }
  // Build a new string letter by letter in outStr:
  String outStr = "";
  String strThisLetter = "";
  String strPreviousLetter = " ";
  // Loop through the list:
  Iterator iter = letterList.iterator();
  while ( iter.hasNext() ) {
    strThisLetter = ( String ) iter.next();
    // Was the previous letter a space?
    if ( strPreviousLetter.equals(" ") == true ) {
      // Yes, this letter to upper case:
      outStr += strThisLetter.toUpperCase();
    } else {
      // No, leave this letter as it is:
      outStr += strThisLetter;
    }
    strPreviousLetter = strThisLetter;
  }
  return outStr;
}

// Free bonus!!!
// Convert the string to sentence case:
public String toSentenceCase( String inStr )
{
  String outStr;
  outStr = inStr.substring(0,1).toUpperCase();
  outStr += inStr.substring(1);
  return outStr;
}