-2

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?

2

2 Answers 2

3

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.)

Sign up to request clarification or add additional context in comments.

2 Comments

Heck, you can have this answer :(
Eclipse confused me, thank you for the answer @JonSkeet)
3

The StringUtils.isNumeric method is defined in the package org.apache.commons.lang3 and not in the one you specified.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.