示例#1
0
  private static PrintWriter argumentToOutput(String arg, Charset outputCharset)
      throws ParseException, IOException {
    if ("-".equals(arg)) {
      return new PrintWriter(new OutputStreamWriter(System.out, outputCharset));
    }

    final File outFile = new File(arg);
    try {
      return new PrintWriter(Files.newBufferedWriter(outFile.toPath(), outputCharset));
    } catch (FileNotFoundException e) {
      throw new ParseException("Output file '" + outFile + "' not found");
    }
  }