// Get DfpUser from "~/dfp.properties".
DfpUser user = new DfpUser();
// Get the AudienceSegmentService.
AudienceSegmentServiceInterface audienceSegmentService =
user.getService(DfpService.V201208.AUDIENCE_SEGMENT_SERVICE);
// Set defaults for page and filterStatement.
AudienceSegmentPage page;
Statement filterStatement = new Statement();
int offset = 0;
do {
// Create a statement to get all audience segments.
filterStatement.setQuery("LIMIT 500 OFFSET " + offset);
// Get audience segments by statement.
page = audienceSegmentService.getAudienceSegmentsByStatement(filterStatement);
if (page.getResults() != null) {
int i = page.getStartIndex();
for (AudienceSegment audienceSegment : page.getResults()) {
System.out.println(i + ") Audience segment with ID \"" + audienceSegment.getId()