通过java获取计算机名
String hostname = "Unknown"; try { InetAddress addr; addr = InetAddress.getLocalHost(); hostname = addr.getHostName(); } catch (UnknownHostException ex) { System.out.println("Hostname can not be resolved"); } logger.info("The computer name is: " + hostname);
时间: 2024-10-08 03:21:02