String ipAddress = "";
try {
for
(Enumeration<NetworkInterface> en = NetworkInterface
.getNetworkInterfaces();
en.hasMoreElements();) {
NetworkInterface
intf = en.nextElement();
for
(Enumeration<InetAddress> enumIpAddr = intf
.getInetAddresses();
enumIpAddr.hasMoreElements();) {
InetAddress
inetAddress = enumIpAddr.nextElement();
if
(!inetAddress.isLoopbackAddress()) {
ipAddress
= inetAddress.getHostAddress().toString();
}
}
}
} catch (SocketException ex)
{
}
No comments:
Post a Comment