Here you can find the source of split(List
public static List<List<String>> split(List<String> list)
//package com.java2s; //License from project: Apache License import java.util.*; public class Main { public static List<List<String>> split(List<String> list) { List<List<String>> lists = new ArrayList<>(); int lastSplit = 0; boolean splited = false; for (int i = 0; i < list.size(); i++) { if (list.get(i).equals("//FILE_SEPARATION_LINE")) { lists.add(list.subList(lastSplit, i)); lastSplit = i + 1;// w w w . j a v a 2 s. c o m splited = true; } } if (!splited) { lists.add(list); } return lists; } }