I'm getting user input that I need to format. I need to remove all leading/trailing spaces and I need to capitalize the first letter of each word.
Here is what I'm trying, however... if you input something with 2 spaces between words, it crashes. How might I solve this?
String formattedInput = "";
String inputLineArray[] = inputLine.getText().toString().trim().split("\\s");
for (int d=0; d<inputLineArray.length; d++) {
formattedInput = formattedInput.trim() + " " +
inputLineArray[d].trim().substring(0,1).toUpperCase() +
inputLineArray[d].trim().substring(1).toLowerCase();
}