示例#1
0
 private static URL argumentToInput(String arg) throws MalformedURLException {
   final File witnessFile = new File(arg);
   if (witnessFile.exists()) {
     return witnessFile.toURI().normalize().toURL();
   } else {
     return new URL(arg);
   }
 }
示例#2
0
 private static InputStream argumentToInputStream(String arg)
     throws MalformedURLException, IOException {
   if ("-".equals(arg)) {
     return System.in;
   }
   final File witnessFile = new File(arg);
   if (witnessFile.exists()) {
     return witnessFile.toURI().normalize().toURL().openStream();
   } else {
     return new URL(arg).openStream();
   }
 }
示例#3
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");
    }
  }