- Slip1
Q 1 Write a java program to display IP Address and Name of client machine.
import java.net.InetAddress;
public class Slip1 {
public static void main(String[] args)
throws Exception {
InetAddress IP = InetAddress.getLocalHost();
System.out.println("Local HostAddress: "+IP.getHostAddress());
String hostname = IP.getHostName();
System.out.println("Local host name: "+hostname);
}
}
No comments:
Post a Comment