zoukankan      html  css  js  c++  java
  • [java语言]——InetAddress类的getByName()方法

    InetAddress---表示互联网协议(IP)地址

       ---InetAddress.getByName("www.163.com")----在给定主机名的情况下确定主机的IP地址

                                                                            ----如果参数为null,获得的是本机的IP地址

    import java.net.*;

    public class MyHost {
             public static void main(String args[]) {
             InetAddress ip = null;

                          try {
                                  ip = InetAddress.getByName("www.baidu.com");// 修改为指定的主机名称
                                  System.out.println(ip.toString());
                                  System.out.println("主机名:" + ip.getHostName());
                                   System.out.println("主机IP地址:" + ip.getHostAddress());
                                    System.out.println("本机IP地址:"+ InetAddress.getLocalHost().getHostAddress());
                                } catch (UnknownHostException e) {
                                             e.printStackTrace();
                                                                                       }

                                                                        }
                                      }

  • 相关阅读:
    vue项目搭建
    轮播 删除中间的还是居中
    随内容增加,背景不设高度自适应,背景图不拉伸和变形
    緢点连接
    左侧背景,右侧数据,根据数据左侧背景自适应
    问题
    手机访问网站,点击手机号码直接拨打电话
    长度超出之后文字变成省略号
    css中vw,vh单位对于UC的兼容性问题
    线性渐变的兼容性写法
  • 原文地址:https://www.cnblogs.com/JasonLGJnote/p/7822992.html
Copyright © 2011-2022 走看看