try {
// Set the property api.adwords.reportDownloadTimeout or call
// ReportDownloader.setReportDownloadTimeout to set a timeout (in milliseconds)
// for CONNECT and READ in report downloads.
ReportDownloadResponse response =
new ReportDownloader(session).downloadReport(query, DownloadFormat.CSV);
FileOutputStream fos = new FileOutputStream(new File(reportFile));
Streams.copy(response.getInputStream(), fos);
fos.close();
System.out.println("Report successfully downloaded: " + reportFile);
} catch (ReportDownloadResponseException e) {