A method to capitalize the first letter of all words in a String
It appears whitespace is destroyed instead of preserved, see your "NOTE". I suspect input like " 123 456 " will output "123456" destroying outer and inner space.  Similarly "a     b" will become "A B", as split will return a lot of empty strings when splitting more than one space.  How about treating it as a stream and if the previous character is whitespace and the next character is in a-z, upper case it, and emit the character and update your previous character placeholder.  You could probably do this with a single regular expression.