Here you can find the source of isPublic(InetAddress inetAddress)
private static boolean isPublic(InetAddress inetAddress)
//package com.java2s; /**/*from w ww . j a v a 2 s .c o m*/ * Aptana Studio * Copyright (c) 2005-2011 by Appcelerator, Inc. All Rights Reserved. * Licensed under the terms of the GNU Public License (GPL) v3 (with exceptions). * Please see the license.html included with this distribution for details. * Any modifications to this file must keep this entire header intact. */ import java.net.InetAddress; public class Main { private static boolean isPublic(InetAddress inetAddress) { String hostAddress = inetAddress.getHostAddress(); if (hostAddress.startsWith("10.") //$NON-NLS-1$ || hostAddress.startsWith("192.168.") //$NON-NLS-1$ || hostAddress.startsWith("169.254.") //$NON-NLS-1$ || hostAddress.startsWith("127.")) { //$NON-NLS-1$ return false; } if (hostAddress.startsWith("172.")) { //$NON-NLS-1$ return !(inetAddress.getAddress()[1] >= 16 && inetAddress.getAddress()[1] <= 31); } return true; } }