/*** Determine whether the given IP address is an intranet IP address ** @ author GaoHuanJie */public class Test {public boolean isInnerIP (String ipAddress) {/* determine whether the IP address is an intranet IP Address */boolean isInnerIp = false; // The default IP address is not an intranet IP address long ipNum = getIpNum (ipAddress);/*** private IP Address: class A 10.0.0.0-10.20.255.255 * Class B 172.16.0.0-255.* Class C 192.168.0.0-192.168.255.255 * Class D 127.0.0.0-127.255.255.255.255 (loop address) **/long aBegin = getIpNum ("10.0.0.0 "); long aEnd = getIpNum ("10.20.255.255"); long bBegin = getIpNum ("172.16.0.0"); long bEnd = getIpNum ("172.31.255.255"); long cBegin = getIpNum ("192.168.0.0 "); long cEnd = getIpNum ("192.168.255.255"); long dBegin = getIpNum ("127.0.0.0"); long dEnd = getIpNum ("plaintext"); isInnerIp = isInner (ipNum, aBegin, aEnd) | isInner (ipNum, bBegin, bEnd) | isInner (ipNum, cBegin, cEnd) | isInner (ipNum, dBegin, dEnd); return isInner Ip;} private long getIpNum (String ipAddress) {/* Number of IP addresses retrieved */String [] ip = ipAddress. split ("\\. "); long a = Integer. parseInt (ip [0]); long B = Integer. parseInt (ip [1]); long c = Integer. parseInt (ip [2]); long d = Integer. parseInt (ip [3]); long ipNum = a * 256*256*256 + B * 256*256 + c * 256 + d; return ipNum ;} private boolean isInner (long userIp, long begin, long end) {return (userIp >=begin) & (userI P <= end);} public static void main (String [] args) {if (new Test (). isInnerIP ("22.8.129.60") {// 172.16.0.119System.out.println ("this IP address is an intranet IP address! ");} Else {System. out. println (" this IP address is an Internet IP address! ");}}}