public int format(String... args) throws UsageException {
    CommandLineOptions parameters = processArgs(args);
    if (parameters.version()) {
      errWriter.println(versionString());
      return 0;
    }
    if (parameters.help()) {
      throw new UsageException();
    }

    JavaFormatterOptions options =
        JavaFormatterOptions.builder()
            .style(parameters.aosp() ? Style.AOSP : Style.GOOGLE)
            .formatJavadoc(parameters.formatJavadoc())
            .build();

    if (parameters.stdin()) {
      return formatStdin(parameters, options);
    } else {
      return formatFiles(parameters, options);
    }
  }
@Test
  public void dryRunFiles() throws Exception {
    Path a = testFolder.newFile("A.java").toPath();
    Path b = testFolder.newFile("B.java").toPath();
    Path c = testFolder.newFile("C.java").toPath();
    Files.write(a, "class A {}\n".getBytes(UTF_8));
    Files.write(b, "class B {\n}\n".getBytes(UTF_8));
    Files.write(c, "class C {\n}\n".getBytes(UTF_8));

    StringWriter out = new StringWriter();
    StringWriter err = new StringWriter();
    Main main = new Main(new PrintWriter(out, true), new PrintWriter(err, true), System.in);
    int exitCode =
        main.format(
            "-n",
            a.toAbsolutePath().toAbsolutePath().toString(),
            b.toAbsolutePath().toString(),
            c.toAbsolutePath().toString());

    assertThat(exitCode).isEqualTo(0);

    assertThat(out.toString())
        .isEqualTo(
            b.toAbsolutePath()
                + System.lineSeparator()
                + c.toAbsolutePath()
                + System.lineSeparator());
    assertThat(err.toString()).isEmpty();
  }