Here you can find the source of isLoopbackAddress(String address)
Parameter | Description |
---|---|
address | address to check |
public static boolean isLoopbackAddress(String address)
//package com.java2s; //License from project: Open Source License import java.net.InetAddress; import java.net.UnknownHostException; public class Main { /**//from ww w . ja v a 2s . c om * Checks if the specified address is a loopback address. This can be one of the following: * <ul> * <li>127.0.0.1</li> * <li>localhost</li> * <li>[::1]</li> * </ul> * * @param address address to check * @return true if the address is a loopback one */ public static boolean isLoopbackAddress(String address) { try { InetAddress inetAddress = InetAddress.getByName(address); return inetAddress.isLoopbackAddress(); } catch (UnknownHostException e) { return false; } } private static boolean isLoopbackAddress(InetAddress address) { return address.isLoopbackAddress(); } }