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 importRemoveErrorParseError() throws Exception {
    Locale backupLocale = Locale.getDefault();
    try {
      Locale.setDefault(Locale.ROOT);

      String[] input = {
        "import java.util.ArrayList;", //
        "import java.util.List;",
        "class Test {",
        "}}",
      };
      StringWriter out = new StringWriter();
      StringWriter err = new StringWriter();
      Main main =
          new Main(
              new PrintWriter(out, true),
              new PrintWriter(err, true),
              new ByteArrayInputStream(joiner.join(input).getBytes(UTF_8)));
      assertThat(main.format("-")).isEqualTo(1);
      assertThat(err.toString()).contains("<stdin>:4:3: error: class, interface");

    } finally {
      Locale.setDefault(backupLocale);
    }
  }