获取本机访问地址

    /**
     * 获取本机访问地址
     * @return
     */
    public static String getIp(){
        String ip = "";
        try {
            InetAddress inet = InetAddress.getLocalHost();
            ip = inet.getHostAddress();
        } catch (UnknownHostException e) {
            e.printStackTrace();
        }
        return ip;
    }

 

posted @ 2018-05-22 15:38  dengrq  阅读(138)  评论(0编辑  收藏  举报