public void getInterfaces() {
try {
Enumeration e = NetworkInterface.getNetworkInterfaces();
while (e.hasMoreElements()) {
NetworkInterface netface = (NetworkInterface) e.nextElement();
System.out.println("Net interface: " + netface.getName());
Enumeration e2 = netface.getInetAddresses();
while (e2.hasMoreElements()) {
InetAddress ip = (InetAddress) e2.nextElement();
System.out.println("IP address: " + ip.toString());
}
}
} catch (Exception e) {
System.out.println("e: " + e);
}
}
Nenhum comentário:
Postar um comentário