Capitalization Algorithm

Since I didn’t find anything on the web here is my solution to the problem (hope it works):

private String getCapitalized(String input){				
	StringBuffer result = new StringBuffer();			
	for(int i=0;i<input.length();i++){
		char c = input.charAt(i);
		char prev = (i>0?input.charAt(i-1):' ');
		if(Character.isLetterOrDigit(c) && !Character.isLetterOrDigit(prev))
			result.append(Character.toUpperCase(c));
		else
			result.append(Character.toLowerCase(c));
	}				
	return result.toString().trim();		
}