String hostAddress = null;
String hostName = null;
try {
InetAddress ip4 = Inet4Address.getLocalHost();
hostAddress = ip4.getHostAddress();
hostname = addr.getHostName();
} catch (UnknownHostException e) {
e.printStackTrace();
}
hostAddress 就是我们本机的ip地址了