java 取得本机器IP地址

引用
取得机器的IP地址

package com.wangyp.ip;

import java.net.InetAddress;

public class GetIP {
	public static void main(String[] args) {
		try {
			InetAddress inet = InetAddress.getLocalHost();
			System.out.println("当前IP地址:" + inet.getHostAddress());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

你可能感兴趣的:(java,.net)