code: public static InetAddress
      getByAddress(String addr) throws UnknownHostException {
          byte[] bytes;
          bytes = toByteArray(addr, IPv4);
          if (bytes != null)
              return InetAddress.getByAddress(bytes);
          bytes = toByteArray(addr, IPv6);
          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.
  The address can be either IPv4 or IPv6.
  
  @param addr The address, in string form
  @return The IP addresses
  @throws UnknownHostException The address is not a valid IP address.