判断ip是内网还是外网
内网IP的范围
Class A: 10.0.0.0 到 10.255.255.255
Class B: 172.16.0.0 到 172.31.255.255
Class C: 192.168.0.0 到 192.168.255.255
public class IpChecker {
private static final Pattern PRIVATE_IP_PATTERN = Pattern.compile(
"^(10\\.([0-9]{1,3}\\.){2}[0-9]{1,3})|" +
"(172\\.(1[6-9]|2[0-9]|3[01])\\.([0-9]{1,3}\\.){1}[0-9]{1,3})|" +
"(192\\.168\\.([0-9]{1,3}\\.){1}[0-9]{1,3})$"
);
public static boolean isPrivateIP(String ip) {
return PRIVATE_IP_PATTERN.matcher(ip).matches();
}
}
下一篇 :python剪辑音频
版权所有,转载时必须以链接形式注明原始出处