Here you can find the source of isIP4(String val)
public static boolean isIP4(String val)
//package com.java2s; //License from project: Apache License import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { private static final String IP4_REGEXP = "^(25[0-5]|2[0-4]\\d|[0-1]\\d{2}|[1-9]?\\d)\\.(25[0-5]|2[0-4]\\d|[0-1]\\d{2}|[1-9]?\\d)\\.(25[0-5]|2[0-4]\\d|[0-1]\\d{2}|[1-9]?\\d)\\.(25[0-5]|2[0-4]\\d|[0-1]\\d{2}|[1-9]?\\d)$"; public static boolean isIP4(String val) { boolean result = false; Pattern p = Pattern.compile(IP4_REGEXP); Matcher m = p.matcher(val); try {/*from ww w . ja v a 2 s .c om*/ return m.matches(); } catch (Exception e) { e.printStackTrace(); } return result; } }