code: public static String formUrlEncode(Map<String, ?> parameters)
      {
          if (parameters == null)
          {
              return null;
          }
  
          StringBuilder sb = new StringBuilder();
  
          // For each key-values pair.
          for (Map.Entry<String, ?> entry : parameters.entrySet())
          {
              String key    = entry.getKey();
              Object values = entry.getValue();
  
              if (values instanceof List)
              {
                  List<?> list = (List<?>)values;
                  values = list.toArray(new String[list.size()]);
              }
  
              appendParameters(sb, key, (String[])values);
          }
  
          if (sb.length() != 0)
          {
              // Drop the last &.
              sb.setLength(sb.length() - 1);
          }
  
          return sb.toString();
      }
docs: Convert the given map to a string in {@code x-www-form-urlencoded} format.
  
  @param parameters
  Pairs of key and values. The type of values must be either
  {@code String[]} or {@code List<String>}.
  
  @return
  A string in {@code x-www-form-urlencoded} format.
  {@code null} is returned if {@code parameters} is {@code null}.
  
  @since 1.24