//noinspection unchecked
return downloadFiles(asList(Pair.create(downloadUrl, fileName)), targetPath);
}
public static boolean downloadFiles(List<Pair<String, String>> urlAndFileNames, String targetPath) {
final DownloadableFileService service = DownloadableFileService.getInstance();
List<DownloadableFileDescription> descriptions = map(urlAndFileNames, new Function<Pair<String, String>, DownloadableFileDescription>() {
@Override public DownloadableFileDescription fun(Pair<String, String> it) {
return service.createFileDescription(it.first + it.second, it.second);
}
});
VirtualFile[] files = service.createDownloader(descriptions, null, null, "").toDirectory(targetPath).download();
return files != null && files.length == urlAndFileNames.size();
}