Here you can find the source of isPrivate(InetAddress addr)
private static boolean isPrivate(InetAddress addr)
//package com.java2s; import java.net.InetAddress; public class Main { private static final int[][] PRIVATE_ADDRS = { { 10 }, { 192, 168 }, { 172, 16 }, { 172, 17 }, { 172, 18 }, { 172, 19 }, { 172, 20 }, { 172, 21 }, { 172, 22 }, { 172, 23 }, { 172, 24 }, { 172, 25 }, { 172, 26 }, { 172, 27 }, { 172, 28 }, { 172, 29 }, { 172, 30 }, { 172, 31 }, }; private static boolean isPrivate(InetAddress addr) { byte[] addrb = addr.getAddress(); for (int i = PRIVATE_ADDRS.length; --i >= 0;) { boolean valid = true; for (int j = 0; j < PRIVATE_ADDRS[i].length; j++) if (PRIVATE_ADDRS[i][j] != (addrb[j] & 0xFF)) { valid = false;/* w w w .j a va 2 s .c om*/ break; } if (valid) return true; } return false; } }