code: public String toQueryString()
     {
        try
        {
           StringBuffer result = new StringBuffer();
  
           if ((null != parameters) && !parameters.isEmpty())
           {
              result.append("?");
              Iterator<Entry<String, List<String>>> iterator = parameters.entrySet().iterator();
              while (iterator.hasNext())
              {
                 Entry<String, List<String>> entry = iterator.next();
                 String key = entry.getKey();
                 List<String> values = entry.getValue();
  
                 if ((key != null) && !"".equals(key))
                 {
                    key = URLEncoder.encode(key, "UTF-8");
                    result.append(key);
  
                    if ((values != null) && !values.isEmpty())
                    {
                       for (int i = 0; i < values.size(); i++)
                       {
                          String value = values.get(i);
                          if ((value != null) && !"".equals(value))
                          {
                             value = URLEncoder.encode(value, "UTF-8");
                             result.append("=" + value);
                          }
                          else if ((value != null) && "".equals(value))
                          {
                             result.append("=");
                          }
  
                          if (i < values.size() - 1)
                          {
                             result.append("&" + key);
                          }
                       }
                    }
                 }
  
                 if (iterator.hasNext())
                 {
                    result.append("&");
                 }
              }
           }
  
           return result.toString();
        }
        catch (UnsupportedEncodingException e)
        {
           throw new PrettyException("Error building query string.", e);
        }
     }
docs: Convert the current parameters to a valid query string, including the leading '?' character. This method
  automatically URLEncodes query-parameter values
  <p>
  
  For example, a {@link QueryString} with the values [key=>value, name=>value1,value2,value3] will become:
  
  <pre>
  
  ?key=value&name=value1&name=value2&name=value3
  </pre>
  
  @return If parameters exist, return a valid query string with leading '?' character. If no parameters exist,
  return an empty string.