Here you can find the source of isInternalHostname(String host)
Parameter | Description |
---|---|
host | the host name to check |
public static boolean isInternalHostname(String host)
//package com.java2s; /*/*from w ww .j ava 2s .com*/ * $Header: Util.java, 14-Jul-2005 03:27:51 luisantonioa Exp $ * * $Author: luisantonioa $ $Date: 14-Jul-2005 03:27:51 $ $Revision: 1 $ $Log: * Util.java,v $ Revision 1 14-Jul-2005 03:27:51 luisantonioa Added copyright * notice * * * This program is free software: you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License along with * this program. If not, see <http://www.gnu.org/licenses/>. */ import java.net.InetAddress; import java.net.UnknownHostException; public class Main { /** * Checks if a host name is internal * * @param host * the host name to check * @return * true: host name is internal<br> * false: host name is external */ public static boolean isInternalHostname(String host) { try { InetAddress addr = InetAddress.getByName(host); return addr.isSiteLocalAddress() || addr.isLoopbackAddress(); } catch (UnknownHostException e) { e.printStackTrace(); } return false; } }