标签:
贴代码
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); } }
标签:
原文地址:http://www.cnblogs.com/zhangdong-ah/p/4326376.html