I am trying to develop a system where there are different nodes that are run on different system or on different ports on the same system.
Now all the nodes create
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.util.Enumeration;
public class IpAddress {
NetworkInterface ifcfg;
Enumeration addresses;
String address;
public String getIpAddress(String host) {
try {
ifcfg = NetworkInterface.getByName(host);
addresses = ifcfg.getInetAddresses();
while (addresses.hasMoreElements()) {
address = addresses.nextElement().toString();
address = address.replace("/", "");
}
} catch (Exception e) {
e.printStackTrace();
}
return ifcfg.toString();
}
}