InetAddress addr = null;
addr = InetAddress.getLocalHost();
byte[] ipAddr = addr.getAddress();
String ipAddrStr = "";
for (int h = 0; h < ipAddr.length; h++) {
if (h > 0) {
ipAddrStr += ".";
}
ipAddrStr += ipAddr[h] & 0xFF;
}
//获取服务器的IP地址
String name = InetAddress.getLocalHost().getHostName(); //获取电脑名