Get ip address of host in java
package com.w3spoint;
import java.net.InetAddress;
public class NetworkTest {
public static void main(String args[]){
try {
InetAddress host = InetAddress.getByName("w3spoint.com");
System.out.println(host.getHostAddress());
} catch(Exception e) {
e.printStackTrace();
}
}
} |
package com.w3spoint; import java.net.InetAddress; public class NetworkTest {
public static void main(String args[]){
try {
InetAddress host = InetAddress.getByName("w3spoint.com");
System.out.println(host.getHostAddress());
} catch(Exception e) {
e.printStackTrace();
}
}
}
Output