StringUtils.isNumeric is undefined method

I have imported that library:

import org.apache.commons.codec.binary.StringUtils;

And tried to use some of methods, but failed:

StringUtils.isNumeric("2398sdf");

IDE keep saying me that, method is undefined. What is wrong here?

Jon Skeet
people
quotationmark

You're using the wrong StringUtils class. You're importing org.apache.commons.codec.binary.StringUtils, but it looks like you want org.apache.commons.lang.StringUtils or org.apache.commons.lang3.StringUtils. The first of these doesn't have an isNumeric method, whereas both of the lang-based ones do.

Obviously this means you'll need the "commons lang" library to be in your classpath. (Which class you import will depend on which version you use.)

people

See more on this question at Stackoverflow