code: public static String encodeArray(final String[] val){
      if (val == null) {
        return null;
      }
  
      int len = val.length;
  
      if (len == 0) {
        return "";
      }
  
      StringBuffer sb = new StringBuffer();
  
      for (int i = 0; i < len; i++) {
        if (i > 0) {
          sb.append(" ");
        }
  
        String s = val[i];
  
        try {
          if (s == null) {
            sb.append("\t");
          } else {
            sb.append(URLEncoder.encode(s, "UTF-8"));
          }
        } catch (Throwable t) {
          throw new RuntimeException(t);
        }
      }
  
      return sb.toString();
    }
docs: Return a String representing the given String array, achieved by
  URLEncoding the individual String elements then concatenating with
  intervening blanks.
  
  @param  val    String[] value to encode
  @return String encoded value