I am trying to find a why in Spring, Java to upper case each word in a string?
Can StringUtils do it?
I am trying to find a why in Spring, Java to upper case each word in a string?
Can StringUtils do it?
You can use the toUpperCase()
method in String
.
String x = "lowercasestring";
x = x.toUpperCase();
System.out.println(x);
The output will be LOWERCASESTRING
EDIT :
You can use the WordUtils
class of the Apache Commons-lang. The capitalize method will convert the first letter of a space separated words. The following code demonstrates it:
String x = "a lower case string";
x = WordUtils.capitalize(x);
System.out.println(x);
The output will be A Lower Case String
. You can also refer the docs for the WordUtils
class here.