public static boolean isIPAddr(String addr) {
        if (StringUtils.isEmpty(addr)) {
            return false;
        }
        String[] ips = StringUtils.split(addr, '.');
        if (ips == null || ips.length != 4) {
            return false;
        }
        try {
            int ipa = Integer.parseInt(ips[0]);
            int ipb = Integer.parseInt(ips[1]);
            int ipc = Integer.parseInt(ips[2]);
            int ipd = Integer.parseInt(ips[3]);
            return ipa >= 0 && ipa <= 255 && ipb >= 0 && ipb <= 255 && ipc >= 0
                    && ipc <= 255 && ipd >= 0 && ipd <= 255;
        } catch (Exception ignored) {
        }
        return false;
    }
public static boolean isIPAddr ( String addr ) { if ( StringUtils . isEmpty ( addr ) ) { return false ; } String [ ] ips = StringUtils . split ( addr , '.' ) ; if ( ips == null || ips . length != 4 ) { return false ; } try { int ipa = Integer . parseInt ( ips [ 0 ] ) ; int ipb = Integer . parseInt ( ips [ 1 ] ) ; int ipc = Integer . parseInt ( ips [ 2 ] ) ; int ipd = Integer . parseInt ( ips [ 3 ] ) ; return ipa >= 0 && ipa <= 255 && ipb >= 0 && ipb <= 255 && ipc >= 0 && ipc <= 255 && ipd >= 0 && ipd <= 255 ; } catch ( Exception ignored ) { } return false ; }
判断字符串是否是一个IP地址

@param addr 字符串
@return true 表示ip地址，否则反之