Java API Tutorial - Java InetAddress .isLoopbackAddress ()








Syntax

InetAddress.isLoopbackAddress() has the following syntax.

public boolean isLoopbackAddress()

Example

In the following code shows how to use InetAddress.isLoopbackAddress() method.

//from   ww  w. j  a  v a  2s .  c  o m
import java.net.InetAddress;

public class Main {
  public static void main(String[] argv) throws Exception {
    InetAddress address = InetAddress.getLoopbackAddress();
    System.out.println("Name: " + address.getHostName());
    System.out.println("Addr: " + address.getHostAddress());
    System.out.println(address.isLoopbackAddress());
  }
}

The code above generates the following result.