com.iwuyc.tools.commons.util.string.VerifyUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of iwuyc-common Show documentation
Show all versions of iwuyc-common Show documentation
Common tools.Include utility classes,and much much more.
The newest version!
package com.iwuyc.tools.commons.util.string;
import com.iwuyc.tools.commons.util.math.NumberUtils;
import com.iwuyc.tools.commons.util.math.Range;
/**
* 校验工具类
* @author Neil
*/
public class VerifyUtils {
private static final Range IP_RANGE = Range.compiler("[0,255]");
private VerifyUtils() {
}
public static boolean isIpV4(String ip) {
String[] values = ip.split("\\.");
for (String item : values) {
if (!NumberUtils.isInteger(item) || !IP_RANGE.inRange(NumberUtils.parse(item))) {
return false;
}
}
return true;
}
}