class NetUtils {

    static public boolean isEqual(String host1, String host2) {
        List<String> host1_ips = new ArrayList<String>();
        List<String> host2_ips = new ArrayList<String>();

        try {
            if (!StringUtils.ok(host1) && !StringUtils.ok(host2))
                return true; // edge case ==> both are null or empty

            if (!StringUtils.ok(host1) || !StringUtils.ok(host2))
                return false; // just one of them is null or empty

            InetAddress[] adds1 = InetAddress.getAllByName(host1);
            InetAddress[] adds2 = InetAddress.getAllByName(host2);

            boolean adds1Empty = false; // readability.  You'll see why below!
            boolean adds2Empty = false;

            if (adds1.length <= 0)
                adds1Empty = true;

            if (adds2.length <= 0)
                adds2Empty = true;

            // I told you!
            if (adds1Empty && adds2Empty) // both
                return true;

            if (adds1Empty || adds2Empty) // one but not the other
                return false;

            for (InetAddress ia : adds1)
                host1_ips.add(ia.getHostAddress());

            for (InetAddress ia : adds2)
                host2_ips.add(ia.getHostAddress());

            for (String h1ip : host1_ips)
                for (String h2ip : host2_ips)
                    if (h1ip.equals(h2ip))
                        return true;

            return false;
        }
        catch (UnknownHostException ex) {
            return false;
        }
    }

    private  NetUtils();

}