code: static void write(Command cmd, OutputStream out) throws UnsupportedEncodingException, IOException {
          encode(cmd.getCommand(), out);
          for (Parameter param : cmd.getParameters()) {
              encode(String.format("=%s=%s", param.getName(), param.hasValue() ? param.getValue() : ""), out);
          }
          String tag = cmd.getTag();
          if ((tag != null) && !tag.equals("")) {
              encode(String.format(".tag=%s", tag), out);
          }
          List<String> props = cmd.getProperties();
          if (!props.isEmpty()) {
              StringBuilder buf = new StringBuilder("=.proplist=");
              for (int i = 0; i < props.size(); ++i) {
                  if (i > 0) {
                      buf.append(",");
                  }
                  buf.append(props.get(i));
              }
              encode(buf.toString(), out);
          }
          for (String query : cmd.getQueries()) {
              encode(query, out);
          }
          out.write(0);
      }
docs: write a command to the output stream