Hi,
Since the
ReportDownloadResponse object gives you access to the
InputStream via
response.getInputStream(), you can save the contents of that stream wherever you'd like. The
DownloadCriteriaReport.java example saves the contents to a file, but you could choose to store the contents elsewhere, e.g., as a blob in a database.
If you simply want to retrieve the bytes in the
InputStream as a byte array, you can use the
Guava I/O utilities as follows:
final ReportDownloadResponse response =
new ReportDownloader(session).downloadReport(reportDefinition);
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
new ByteSource() {
@Override
public InputStream openStream() throws IOException {
return response.getInputStream();
}
}.copyTo(outStream);
byte[] contentBytes = outStream.toByteArray();
Note that you cannot serialize the InputStream itself, as that type is not Serializable (it represents the byte source, not the actual contents of the source).
Thanks,
Josh, AdWords API Team