大家好,这是我的第一个博客,请多多关照。
获取本机名
1 public static String getServerName() { 2 try { 3 InetAddress addr = InetAddress.getLocalHost(); 4 String ip = addr.getHostAddress(); 5 String host = addr.getHostName().toString();// 获得本机名称 6 return ip; 7 8 } catch (Exception e) { 9 return "未知"; 10 } 11 }