java中如何获取本机IP地址

InetAddress inetAddress=InetAddress.getLocalHost();
String userIP=inetAddress.getHostAddress().toString();//获得本机Ip

包是import java.net.InetAddress;

你可能感兴趣的:(java中如何获取本机IP地址)