code: public static InetAddress
      getByAddress(String addr, int family) throws UnknownHostException {
          if (family != IPv4 && family != IPv6)
              throw new IllegalArgumentException("unknown address family");
          byte[] bytes;
          bytes = toByteArray(addr, family);
          if (bytes != null)
              return InetAddress.getByAddress(bytes);
          throw new UnknownHostException("Invalid address: " + addr);
      }
docs: Converts an address from its string representation to an IP address in
  a particular family.
  
  @param addr   The address, in string form
  @param family The address family, either IPv4 or IPv6.
  @return The IP addresses
  @throws UnknownHostException The address is not a valid IP address in
  the specified address family.