java获取系统当前服务器IP地址

public String getServiceIp(){
  InetAddress address;

  String myIp;
    try {
      address = InetAddress.getLocalhost();
      myIp = address.getHostAddress();
    } catch (UnknowHostException e) {
      e.printStackTrace();
    }
  return myIp;
}

posted @ 2018-01-08 21:13  秦先生的客栈  Views(1507)  Comments(0Edit  收藏  举报