code: public static void runExample(AdManagerServices adManagerServices, AdManagerSession session)
        throws IOException {
      // Get the PublisherQueryLanguageService.
      PublisherQueryLanguageServiceInterface pqlService =
          adManagerServices.get(session, PublisherQueryLanguageServiceInterface.class);
  
      // Create statement to select all line items.
      StatementBuilder statementBuilder =
          new StatementBuilder()
              .select("Id, Name, Status")
              .from("Line_Item")
              .orderBy("Id ASC")
              .offset(0)
              .limit(StatementBuilder.SUGGESTED_PAGE_LIMIT);
  
      // Default for result sets.
      ResultSet combinedResultSet = null;
      ResultSet resultSet;
      int i = 0;
  
      do {
        // Get all line items.
        resultSet = pqlService.select(statementBuilder.toStatement());
  
        // Combine result sets with previous ones.
        combinedResultSet =
            combinedResultSet == null
                ? resultSet
                : Pql.combineResultSets(combinedResultSet, resultSet);
  
        System.out.printf(
            "%d) %d line items beginning at offset %d were found.%n",
            i++,
            resultSet.getRows() == null ? 0 : resultSet.getRows().length,
            statementBuilder.getOffset());
  
        statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
      } while (resultSet.getRows() != null && resultSet.getRows().length > 0);
  
      // Change to your file location.
      String filePath = File.createTempFile("Line-Items-", ".csv").toString();
  
      // Write the result set to a CSV.
      CsvFiles.writeCsv(Pql.resultSetToStringArrayList(combinedResultSet), filePath);
  
      System.out.printf("Line items saved to: %s%n", filePath);
    }
docs: Runs the example.
  
  @param adManagerServices the services factory.
  @param session the session.
  @throws ApiException if the API request failed with one or more service errors.
  @throws RemoteException if the API request failed due to other errors.
  @throws IOException if unable to write the response to a file.