You are on page 1of 1

import java.net.

InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.net.UnknownHostException;

public class getByInetAddress { {

try {
InetAddress local =
InetAddress.getByName("127.0.0.1");
NetworkInterface ni =
NetworkInterface.getByInetAddress(local);
if (ni == null) {
System.err.println("That's weird. No local
loopback address.");
}
}
catch (SocketException ex) {
System.err.println("Could not list network
interfaces." );
} catch (UnknownHostException ex1) {
System.err.println("That's weird. Could not
lookup 127.0.0.1.");
}
}
}

You might also like