Esempio n. 1
0
 private InputSource fileToInputSource(File source) {
   try {
     String url = source.toURL().toExternalForm();
     return new InputSource(Util.escapeSpace(url));
   } catch (MalformedURLException e) {
     return new InputSource(source.getPath());
   }
 }
Esempio n. 2
0
 /**
  * Parses a token to a file (or a set of files) and add them as {@link InputSource} to the
  * specified list.
  *
  * @param suffix If the given token is a directory name, we do a recusive search and find all
  *     files that have the given suffix.
  */
 private void addFile(String name, List<InputSource> target, String suffix)
     throws BadCommandLineException {
   Object src;
   try {
     src = Util.getFileOrURL(name);
   } catch (IOException e) {
     throw new BadCommandLineException(Messages.format(Messages.NOT_A_FILE_NOR_URL, name));
   }
   if (src instanceof URL) {
     target.add(absolutize(new InputSource(Util.escapeSpace(((URL) src).toExternalForm()))));
   } else {
     File fsrc = (File) src;
     if (fsrc.isDirectory()) {
       addRecursive(fsrc, suffix, target);
     } else {
       target.add(absolutize(fileToInputSource(fsrc)));
     }
   }
 }