获得 Client 的相关信息

Posted small-sunshine

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了获得 Client 的相关信息相关的知识,希望对你有一定的参考价值。

1、获得 Client 的相关信息

package com.shine.sun.small;

import java.net.InetAddress;

@Slf4j
public class netInfo{

  public static  void main(String args[]){

      InetAddress addr = InetAddress.getLocalHost();
      String  ip = addr.getHostAddress().toString();  // 172.16.11.160
      String  hostName = addr.getHostName().toString();  //small-sunshine
      log.info("===========本地的ip为:hostName【{}】=======================>", ip);
      log.info("===========本地的hostName为:hostName【{}】=================>", hostName);
  }
}

以上是关于获得 Client 的相关信息的主要内容,如果未能解决你的问题,请参考以下文章