NetworkInterface isLoopback Example
NetworkInterface class isLoopback example. This example shows you how to use isLoopback method.
NetworkInterface class isLoopback example. public boolean isLoopback() throws SocketException Returns whether a network interface is a loopback interface.
Here is the code
/*
* @ # IsLoopback.java
* A class repersenting use to IsLoopback method
* of URL class in java.net package
* version 23 June 2008
* author Rose India
*/
import java.net.*;
public class IsLoopback {
public static void main(String args[]) throws Exception {
byte b[] = {127, 0, 0, 1};
InetAddress inetAddress = InetAddress.getByAddress(b);
NetworkInterface networkInterface =
NetworkInterface.getByInetAddress(inetAddress);
System.out.println("network interface is a loopback interface : " +
networkInterface.isLoopback());
}
} |
Output
| network interface is a loopback interface : true |
|