InetAddress ia = InetAddress.parseNumericAddress(host); if (ia instanceof Inet4Address) { return true;
/** * Returns true if the string is a valid numeric IPv4 or IPv6 address (such as "192.168.0.1"). * This copes with all forms of address that Java supports, detailed in the {@link InetAddress} * class documentation. * * @hide used by frameworks/base to ensure that a getAllByName won't cause a DNS lookup. */ public static boolean isNumeric(String address) { //InetAddress inetAddress = parseNumericAddressNoThrow(address); //return inetAddress != null && disallowDeprecatedFormats(address, inetAddress) != null; try { parseNumericAddress(address); return true; } catch (Throwable t) { return false; } }
/** * Gets all IP addresses associated with the given {@code host} identified * by name or literal IP address. The IP address is resolved by the * configured name service. If the host name is empty or {@code null} an * {@code UnknownHostException} is thrown. If the host name is a literal IP * address string an array with the corresponding single {@code InetAddress} * is returned. * * @param host the hostname or literal IP string to be resolved. * @return the array of addresses associated with the specified host. * @throws UnknownHostException if the address lookup fails. */ public static InetAddress[] getAllByName(String host) throws UnknownHostException { //return getAllByNameImpl(host).clone(); try { return new InetAddress[]{parseNumericAddress(host)}; } catch (Throwable t) { throw new UnknownHostException(host); } }
InetAddress ia = InetAddress.parseNumericAddress(host); if (ia instanceof Inet4Address) { return true;
InetAddress ia = InetAddress.parseNumericAddress(host); if (ia instanceof Inet4Address) { return true;
InetAddress ia = InetAddress.parseNumericAddress(host); if (ia instanceof Inet4Address) { return true;
InetAddress ia = InetAddress.parseNumericAddress(host); if (ia instanceof Inet4Address) { return true;
InetAddress ia = InetAddress.parseNumericAddress(host); if (ia instanceof Inet4Address) { return true;
InetAddress ia = InetAddress.parseNumericAddress(host); if (ia instanceof Inet4Address) { return true;
InetAddress ia = InetAddress.parseNumericAddress(host); if (ia instanceof Inet4Address) { return true;