String ids = "1,2,3,4,5";
List<Integer> idsList = Arrays.stream(ids.split(",")).map(s -> Integer.parseInt(s.trim())).collect(Collectors.toList());