Enumeration netInterfaces=NetworkInterface.getNetworkInterfaces();
while(netInterfaces.hasMoreElements()){
NetworkInterface ni=(NetworkInterface)netInterfaces.nextElement();
System.out.println(ni.getName());
ip=(InetAddress) ni.getInetAddresses().nextElement();
if( !ip.isSiteLocalAddress() && !ip.isLoopbackAddress() && ip.getHostAddress().indexOf(":")==-1){
System.out.println("Interface "+ni.getName()+" seems to be InternetInterface. I'll take it...");
break;
}else{
ip=null;
No comments:
Post a Comment