programming-examples/java/Numerical_Problems/java program to determine IP Address & hostname of Local Computer.java

10 lines
375 B
Java
Raw Normal View History

2019-11-15 12:59:38 +01:00
import java.net.InetAddress;
public class Main {
public static void main(String[] args)
throws Exception {
InetAddress addr = InetAddress.getLocalHost();
System.out.println("Local HostAddress: "+addr.getHostAddress());
String hostname = addr.getHostName();
System.out.println("Local host name: "+hostname);
}
}