code: private static void listAssignmentsByTask(ProjectFile file)
     {
        for (Task task : file.getTasks())
        {
           System.out.println("Assignments for task " + task.getName() + ":");
  
           for (ResourceAssignment assignment : task.getResourceAssignments())
           {
              Resource resource = assignment.getResource();
              String resourceName;
  
              if (resource == null)
              {
                 resourceName = "(null resource)";
              }
              else
              {
                 resourceName = resource.getName();
              }
  
              System.out.println("   " + resourceName);
           }
        }
  
        System.out.println();
     }
docs: This method displays the resource assignments for each task. This time
  rather than just iterating through the list of all assignments in
  the file, we extract the assignments on a task-by-task basis.
  
  @param file MPX file