贴代码

GetIP.java

package com.datongsoft.wg.common.util;

import java.net.InetAddress;
public class GetIP {

	/**
	 * @param args
	 * @throws Exception 
	 */
	public static void main(String[] args) throws Exception {
		 InetAddress addr = InetAddress.getLocalHost();   
         String ip=addr.getHostAddress().toString(); //获取本机ip   
         String hostName=addr.getHostName().toString(); //获取本机计算机名称   
         System.out.println(ip);
         System.out.println(hostName);
	}

}

  

相关文章:

  • 2021-11-28
  • 2021-12-13
  • 2021-11-27
  • 2021-11-26
  • 2021-12-25
  • 2022-12-23
  • 2021-09-19
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-12
  • 2022-02-16
  • 2022-12-23
  • 2022-01-16
相关资源
相似解决方案