import java.net.*;
import java.io.*;
public class GetHostName{
public static void main(String [] args) {
try {
InetAddress addr = InetAddress.getLocalHost();
byte[] ipAddr = addr.getAddress();
String hostname = addr.getHostName();
System.out.println("hostname="+hostname);
} catch (UnknownHostException e) {
}
}
}
out put
host name=system-1
import java.io.*;
public class GetHostName{
public static void main(String [] args) {
try {
InetAddress addr = InetAddress.getLocalHost();
byte[] ipAddr = addr.getAddress();
String hostname = addr.getHostName();
System.out.println("hostname="+hostname);
} catch (UnknownHostException e) {
}
}
}
out put
host name=system-1
No comments:
Post a Comment