package test;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.ArrayList;
public class TestLocalIP {
public static void main(String[] args) throws UnknownHostException {
ArrayList<String> ips = new ArrayList<String>();
ips.add("10.205.23.168");
ips.add("192.168.0.1");
ips.add("127.0.0.1");
ips.add("1.1.1.1");
for (String ip : ips) {
InetAddress ad = InetAddress.getByName(ip);
System.out.println("\n\n" + ip);
System.out.println("\n\tLocal Site: " + ad.isSiteLocalAddress());
System.out.println("\n\tLoopback: " + ad.isLoopbackAddress());
}
}
}
Niciun comentariu:
Trimiteți un comentariu