/** * Returns an {@link Inet4Address}, given a byte array representation of the IPv4 address. * * @param bytes byte array representing an IPv4 address (should be of length 4) * @return {@link Inet4Address} corresponding to the supplied byte array * @throws IllegalArgumentException if a valid {@link Inet4Address} can not be created */ private static Inet4Address getInet4Address(byte[] bytes) { Preconditions.checkArgument(bytes.length == 4, "Byte array has invalid length for an IPv4 address: %s != 4.", bytes.length); // Given a 4-byte array, this cast should always succeed. return (Inet4Address) bytesToInetAddress(bytes); }
/** * Returns the {@link InetAddress} having the given string representation. * * <p>This deliberately avoids all nameservice lookups (e.g. no DNS). * * @param ipString {@code String} containing an IPv4 or IPv6 string literal, e.g. * {@code "192.168.0.1"} or {@code "2001:db8::1"} * @return {@link InetAddress} representing the argument * @throws IllegalArgumentException if the argument is not a valid IP string literal */ public static InetAddress forString(String ipString) { byte[] addr = ipStringToBytes(ipString); // The argument was malformed, i.e. not an IP string literal. if (addr == null) { throw formatIllegalArgumentException("'%s' is not an IP string literal.", ipString); } return bytesToInetAddress(addr); }
return bytesToInetAddress(addr);
/** * Returns an {@link Inet4Address}, given a byte array representation of the IPv4 address. * * @param bytes byte array representing an IPv4 address (should be of length 4) * @return {@link Inet4Address} corresponding to the supplied byte array * @throws IllegalArgumentException if a valid {@link Inet4Address} can not be created */ private static Inet4Address getInet4Address(byte[] bytes) { Preconditions.checkArgument(bytes.length == 4, "Byte array has invalid length for an IPv4 address: %s != 4.", bytes.length); // Given a 4-byte array, this cast should always succeed. return (Inet4Address) bytesToInetAddress(bytes); }
/** * Returns an {@link Inet4Address}, given a byte array representation of the IPv4 address. * * @param bytes byte array representing an IPv4 address (should be of length 4) * @return {@link Inet4Address} corresponding to the supplied byte array * @throws IllegalArgumentException if a valid {@link Inet4Address} can not be created */ private static Inet4Address getInet4Address(byte[] bytes) { Preconditions.checkArgument(bytes.length == 4, "Byte array has invalid length for an IPv4 address: %s != 4.", bytes.length); // Given a 4-byte array, this cast should always succeed. return (Inet4Address) bytesToInetAddress(bytes); }
/** * Returns an {@link Inet4Address}, given a byte array representation of the IPv4 address. * * @param bytes byte array representing an IPv4 address (should be of length 4) * @return {@link Inet4Address} corresponding to the supplied byte array * @throws IllegalArgumentException if a valid {@link Inet4Address} can not be created */ private static Inet4Address getInet4Address(byte[] bytes) { Preconditions.checkArgument(bytes.length == 4, "Byte array has invalid length for an IPv4 address: %s != 4.", bytes.length); // Given a 4-byte array, this cast should always succeed. return (Inet4Address) bytesToInetAddress(bytes); }
/** * Returns an {@link Inet4Address}, given a byte array representation of the IPv4 address. * * @param bytes byte array representing an IPv4 address (should be of length 4) * @return {@link Inet4Address} corresponding to the supplied byte array * @throws IllegalArgumentException if a valid {@link Inet4Address} can not be created */ private static Inet4Address getInet4Address(byte[] bytes) { Preconditions.checkArgument(bytes.length == 4, "Byte array has invalid length for an IPv4 address: %s != 4.", bytes.length); // Given a 4-byte array, this cast should always succeed. return (Inet4Address) bytesToInetAddress(bytes); }
/** * Returns an {@link Inet4Address}, given a byte array representation of the IPv4 address. * * @param bytes byte array representing an IPv4 address (should be of length 4) * @return {@link Inet4Address} corresponding to the supplied byte array * @throws IllegalArgumentException if a valid {@link Inet4Address} can not be created */ private static Inet4Address getInet4Address(byte[] bytes) { Preconditions.checkArgument(bytes.length == 4, "Byte array has invalid length for an IPv4 address: %s != 4.", bytes.length); // Given a 4-byte array, this cast should always succeed. return (Inet4Address) bytesToInetAddress(bytes); }
/** * Returns an {@link Inet4Address}, given a byte array representation of the IPv4 address. * * @param bytes byte array representing an IPv4 address (should be of length 4) * @return {@link Inet4Address} corresponding to the supplied byte array * @throws IllegalArgumentException if a valid {@link Inet4Address} can not be created */ private static Inet4Address getInet4Address(byte[] bytes) { Preconditions.checkArgument(bytes.length == 4, "Byte array has invalid length for an IPv4 address: %s != 4.", bytes.length); // Given a 4-byte array, this cast should always succeed. return (Inet4Address) bytesToInetAddress(bytes); }
/** * Returns the {@link InetAddress} having the given string representation. * * <p>This deliberately avoids all nameservice lookups (e.g. no DNS). * * @param ipString {@code String} containing an IPv4 or IPv6 string literal, e.g. * {@code "192.168.0.1"} or {@code "2001:db8::1"} * @return {@link InetAddress} representing the argument * @throws IllegalArgumentException if the argument is not a valid IP string literal */ public static InetAddress forString(String ipString) { byte[] addr = ipStringToBytes(ipString); // The argument was malformed, i.e. not an IP string literal. if (addr == null) { throw formatIllegalArgumentException("'%s' is not an IP string literal.", ipString); } return bytesToInetAddress(addr); }
/** * Returns the {@link InetAddress} having the given string representation. * * <p>This deliberately avoids all nameservice lookups (e.g. no DNS). * * @param ipString {@code String} containing an IPv4 or IPv6 string literal, e.g. * {@code "192.168.0.1"} or {@code "2001:db8::1"} * @return {@link InetAddress} representing the argument * @throws IllegalArgumentException if the argument is not a valid IP string literal */ public static InetAddress forString(String ipString) { byte[] addr = ipStringToBytes(ipString); // The argument was malformed, i.e. not an IP string literal. if (addr == null) { throw formatIllegalArgumentException("'%s' is not an IP string literal.", ipString); } return bytesToInetAddress(addr); }
/** * Returns the {@link InetAddress} having the given string representation. * * <p>This deliberately avoids all nameservice lookups (e.g. no DNS). * * @param ipString {@code String} containing an IPv4 or IPv6 string literal, e.g. * {@code "192.168.0.1"} or {@code "2001:db8::1"} * @return {@link InetAddress} representing the argument * @throws IllegalArgumentException if the argument is not a valid IP string literal */ public static InetAddress forString(String ipString) { byte[] addr = ipStringToBytes(ipString); // The argument was malformed, i.e. not an IP string literal. if (addr == null) { throw formatIllegalArgumentException("'%s' is not an IP string literal.", ipString); } return bytesToInetAddress(addr); }
/** * Returns the {@link InetAddress} having the given string representation. * * <p>This deliberately avoids all nameservice lookups (e.g. no DNS). * * @param ipString {@code String} containing an IPv4 or IPv6 string literal, e.g. * {@code "192.168.0.1"} or {@code "2001:db8::1"} * @return {@link InetAddress} representing the argument * @throws IllegalArgumentException if the argument is not a valid IP string literal */ public static InetAddress forString(String ipString) { byte[] addr = ipStringToBytes(ipString); // The argument was malformed, i.e. not an IP string literal. if (addr == null) { throw formatIllegalArgumentException("'%s' is not an IP string literal.", ipString); } return bytesToInetAddress(addr); }
/** * Returns the {@link InetAddress} having the given string representation. * * <p>This deliberately avoids all nameservice lookups (e.g. no DNS). * * @param ipString {@code String} containing an IPv4 or IPv6 string literal, e.g. * {@code "192.168.0.1"} or {@code "2001:db8::1"} * @return {@link InetAddress} representing the argument * @throws IllegalArgumentException if the argument is not a valid IP string literal */ public static InetAddress forString(String ipString) { byte[] addr = ipStringToBytes(ipString); // The argument was malformed, i.e. not an IP string literal. if (addr == null) { throw formatIllegalArgumentException("'%s' is not an IP string literal.", ipString); } return bytesToInetAddress(addr); }
/** * Returns the {@link InetAddress} having the given string representation. * * <p>This deliberately avoids all nameservice lookups (e.g. no DNS). * * @param ipString {@code String} containing an IPv4 or IPv6 string literal, e.g. * {@code "192.168.0.1"} or {@code "2001:db8::1"} * @return {@link InetAddress} representing the argument * @throws IllegalArgumentException if the argument is not a valid IP string literal */ public static InetAddress forString(String ipString) { byte[] addr = ipStringToBytes(ipString); // The argument was malformed, i.e. not an IP string literal. if (addr == null) { throw formatIllegalArgumentException("'%s' is not an IP string literal.", ipString); } return bytesToInetAddress(addr); }
return bytesToInetAddress(addr);
return bytesToInetAddress(addr);
return bytesToInetAddress(addr);