java获取当前服务器ip

    public static String getIp(){
        try {
        InetAddress ia=InetAddress.getLocalHost();
//        String localname=ia.getHostName();
        String localip=ia.getHostAddress();
        return localip;
        } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        return "500";
        }

posted @ 2019-10-31 10:28  _Lawrence  阅读(6003)  评论(0编辑  收藏  举报