// Get the ContactService.
ContactServiceInterface contactService =
user.getService(DfpService.V201302.CONTACT_SERVICE);
// Set defaults for page and filterStatement.
ContactPage page = new ContactPage();
Statement filterStatement = new Statement();
int offset = 0;
do {
// Create a statement to get all contacts.
filterStatement.setQuery("LIMIT 500 OFFSET " + offset);
// Get contacts by statement.
page = contactService.getContactsByStatement(filterStatement);
if (page.getResults() != null) {
int i = page.getStartIndex();
for (Contact contact : page.getResults()) {
System.out.printf(
"%s) Contact with ID \"%d\" and name \"%s\" was found.\n", i++,
contact.getId(), contact.getName());
}
}
offset += 500;
} while (offset < page.getTotalResultSetSize());
System.out.println("Number of results found: " + page.getTotalResultSetSize());
} catch (Exception e) {
e.printStackTrace();
}
}