use of org.jabref.logic.importer.ImportException in project jabref by JabRef.
the class ArgumentProcessor method importFile.
private static Optional<ParserResult> importFile(Path file, String importFormat) {
try {
if (!"*".equals(importFormat)) {
System.out.println(Localization.lang("Importing") + ": " + file);
ParserResult result = Globals.IMPORT_FORMAT_READER.importFromFile(importFormat, file);
return Optional.of(result);
} else {
// * means "guess the format":
System.out.println(Localization.lang("Importing in unknown format") + ": " + file);
ImportFormatReader.UnknownFormatImport importResult = Globals.IMPORT_FORMAT_READER.importUnknownFormat(file);
System.out.println(Localization.lang("Format used") + ": " + importResult.format);
return Optional.of(importResult.parserResult);
}
} catch (ImportException ex) {
System.err.println(Localization.lang("Error opening file") + " '" + file + "': " + ex.getLocalizedMessage());
return Optional.empty();
}
}
Aggregations