// Change to your file location.
String folderPath = "/path/to/folder";
// Change to your preferred export format.
ExportFormat exportFormat = ExportFormat.CSV_DUMP;
// Construct file path to download the report to.
String filePath = folderPath + File.separator + "report-" + System.currentTimeMillis()
+ "." + exportFormat.toString().split("_")[0].toLowerCase() + ".gz";
System.out.print("Downloading report to " + filePath + "...");
String downloadUrl = reportService.getReportDownloadURL(reportJobId, exportFormat);