public class Address {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        InetAddress ip;
        try {
            ip = InetAddress.getLocalHost();
            String localname = ip.getHostName();
            String localip = ip.getHostAddress();
            System.out.println(localname);
            System.out.println(localip);
        } catch (Exception e) {
            // TODO: handle exception
            e.printStackTrace();
        }
    }

}

 

相关文章:

  • 2021-09-18
  • 2021-07-18
  • 2021-12-19
  • 2022-02-13
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-02-10
  • 2021-04-23
  • 2022-01-16
  • 2021-10-24
  • 2021-11-27
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案