这个网上很多,主要是机器必须支持ICMP和NETBIOS协议。你参考一下:
public String getIP()
{
InetAddress inet;
try {
inet =
InetAddress.getLocalHost();
InetAddress.getByName("");
return
inet.getHostAddress();
} catch (UnknownHostException e) {
// TODO
Auto-generated catch block
e.printStackTrace();
}
return "";
}