I was using the following:
String x;
...
...
// x gets set somewhere in this code
String y = x.replaceAll("\\s+", " ").trim();
Then I found org.apache.commons.lang3.StringUtils.normalizeSpace() which does the same thing. So at the top of my class I added
import org.apache.commons.lang3.StringUtils;
and called
String y = normalizeSpace(x);
but it gave me a method not found error and suggested I create the method.
So I tried
import org.apache.commons.lang3.StringUtils.*;
but the same problem. Anyone have an idea what is wrong?
Yes I can, and do, use
String y = org.apache.commons.lang3.StringUtils.normalizeSpace(x);
but it gets awkward typing the entire path every time.
Oh, and I did not get a syntax error on either of the import statements. And I guess I could go back to the replace and trim but StringUtils has a lot of other methods which would be good to use also.