All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.iwuyc.tools.commons.util.string.VerifyUtils Maven / Gradle / Ivy

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;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy