use of org.jabref.logic.importer.OutputPrinter in project jabref by JabRef.
the class ArgumentProcessor method importFile.
private static Optional<ParserResult> importFile(String argument) {
String[] data = argument.split(",");
String address = data[0];
Path file;
if (address.startsWith("http://") || address.startsWith("https://") || address.startsWith("ftp://")) {
// Download web resource to temporary file
try {
file = new URLDownload(address).toTemporaryFile();
} catch (IOException e) {
System.err.println(Localization.lang("Problem downloading from %1", address) + e.getLocalizedMessage());
return Optional.empty();
}
} else {
if (OS.WINDOWS) {
file = Paths.get(address);
} else {
file = Paths.get(address.replace("~", System.getProperty("user.home")));
}
}
String importFormat;
if (data.length > 1) {
importFormat = data[1];
} else {
importFormat = "*";
}
Optional<ParserResult> importResult = importFile(file, importFormat);
importResult.ifPresent(result -> {
OutputPrinter printer = new SystemOutputPrinter();
if (result.hasWarnings()) {
printer.showMessage(result.getErrorMessage());
}
});
return importResult;
}
Aggregations