How to convert a page of objects to list in spring data

Page<Video> videos = videoRepository.findAllVideos(new PageRequest(1, 50));
List<Video> videosList = videos.getContent();

You can use the above code to get the list of videos from page


Try this solution (and avoid all exception risks) :

Page<Video> videoPage = videoRepository.findAllVideos(new PageRequest(1, 50));
List<Video> videoList = new ArrayList<Video>();
if(videoPage != null && videoPage.hasContent()) {
    videoList = videoPage.getContent();
}