Program:
import java.net.*;
import java.io.*;
public class SystemDetails{
public static void main(String args[]) throws Exception {
InetAddress ipaddress =InetAddress.getLocalHost();
System.out.println("Host and Address :"+ipaddress);
System.out.println("Host name :"+ipaddress.getHostName());
String n=ipaddress.toString();
System.out.println("IP address :"+n.substring(n.indexOf("/")+1));
System.out.println("Is It Local IP address: "+ipaddress.isAnyLocalAddress());
}
}
OUTPUT:
java SystemDetails
Host and Address :praveenreddy-PC/10.50.50.189
Host name :praveenreddy-PC
IP address :10.50.50.189
Host Name: false
import java.net.*;
import java.io.*;
public class SystemDetails{
public static void main(String args[]) throws Exception {
InetAddress ipaddress =InetAddress.getLocalHost();
System.out.println("Host and Address :"+ipaddress);
System.out.println("Host name :"+ipaddress.getHostName());
String n=ipaddress.toString();
System.out.println("IP address :"+n.substring(n.indexOf("/")+1));
System.out.println("Is It Local IP address: "+ipaddress.isAnyLocalAddress());
}
}
OUTPUT:
java SystemDetails
Host and Address :praveenreddy-PC/10.50.50.189
Host name :praveenreddy-PC
IP address :10.50.50.189
Host Name: false
0 comments:
Post a Comment