-4

I am trying to find a why in Spring, Java to upper case each word in a string?

Can StringUtils do it?

Rahul Bobhate
  • 4,892
  • 3
  • 25
  • 48
SJS
  • 5,607
  • 19
  • 78
  • 105

1 Answers1

2

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.

Rahul Bobhate
  • 4,892
  • 3
  • 25
  • 48