code: public static InetAddress InetAddressByIPv4(String address) {
      StringTokenizer addressTokens = new StringTokenizer(address, ".");
      byte[] bytes;
      if (addressTokens.countTokens() == 4) {
        bytes = new byte[]{
            getByBytes(addressTokens),
            getByBytes(addressTokens),
            getByBytes(addressTokens),
            getByBytes(addressTokens)
        };
      }
      else {
        return null;
      }
  
      try {
        return InetAddress.getByAddress(bytes);
      } catch (UnknownHostException e) {
        return null;
      }
    }
docs: Convert defined string to IPv4 object instance
  @param address string representation of ip address
  @return IPv4 object instance