reportDefinition.setDownloadFormat(DownloadFormat.CSV);
reportDefinition.setIncludeZeroImpressions(false);
reportDefinition.setSelector(selector);
FileOutputStream fos = new FileOutputStream(new File(reportFile));
ReportDownloadResponse response = ReportUtils.downloadReport(user, reportDefinition, fos);
if (response.getHttpStatus() == HttpURLConnection.HTTP_OK) {
System.out.println("Report successfully downloaded: " + reportFile);
} else {
System.out.println("Report was not downloaded. " + response.getHttpStatus() + ": "
+ response.getHttpResponseMessage());
}
} catch (Exception e) {
e.printStackTrace();
}
}