获取电脑 ip 地址 及系统

public static void main(String[] args) throws UnknownHostException {
//获取电脑系统 结果:os.name:Windows 10
String property = System.getProperty("os.name");
System.out.println("os.name:" + property);
//获取ip 地址
InetAddress localHost = InetAddress.getLocalHost();
System.out.println("HostAddress:" + localHost.getHostAddress());
//获取主机名称
System.out.println("HostName:" + localHost.getHostName());
}
posted @ 2019-11-20 17:40  明天,你好啊  阅读(265)  评论(0编辑  收藏  举报