通过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);

 

相关文章:

  • 2021-08-18
  • 2022-12-23
  • 2022-12-23
  • 2021-12-07
  • 2022-12-23
  • 2021-10-22
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-07-03
  • 2021-06-29
  • 2021-09-12
  • 2022-12-23
  • 2022-12-23
  • 2021-10-28
相关资源
相似解决方案