code: public static String printToString(UnknownFieldSet fields) {
          try {
              StringBuilder text = new StringBuilder();
              print(fields, text);
              return text.toString();
          } catch (IOException e) {
              throw new RuntimeException("Writing to a StringBuilder threw an IOException (should never "
                                                         + "happen).",
                                         e);
          }
      }
docs: Like {@code print()}, but writes directly to a {@code String} and returns it.