use of org.monarchinitiative.loinc2hpo.io.FileDownloader in project loinc2hpo by monarch-initiative.
the class DownloadCommand method downloadHpOntologyIfNeeded.
private void downloadHpOntologyIfNeeded() {
File f = new File(String.format("%s%shp.obo", downloadDirectory, File.separator));
if (f.exists()) {
logger.trace(String.format("Cowardly refusing to download hp.obo since we found it at %s", f.getAbsolutePath()));
return;
}
FileDownloader downloader = new FileDownloader();
try {
URL url = new URL(HP_OBO);
logger.debug("Created url from " + HP_OBO + ": " + url.toString());
downloader.copyURLToFile(url, new File(f.getAbsolutePath()));
} catch (MalformedURLException e) {
logger.error("Malformed URL for hp.obo");
logger.error(e, e);
} catch (FileDownloadException e) {
logger.error("Error downloading hp.obo");
logger.error(e, e);
}
logger.trace(String.format("Successfully downloaded hp.obo file at %s", f.getAbsolutePath()));
}
Aggregations