import java.net.*;
import java.io.*;
class host {
public static void main(String args[]) {
try {
InetAddress inetadd;
inetadd=InetAddress.getLocalHost();
System. out. println("hostname="+inetadd.getHostName());//取得主机名
System. out. println(inetadd.toString() );//取得主机名和ip地址字符串
}
catch(Exception e) {
System.out.println(e);
}
}
}