//原始长字符串strContext
String strContext = "长字符串................................";
ArrayList<String> arrayList = new ArrayList(5);
int totalNo = strContext.length();
//小字符串长度pageSize
int pageSize = 20;
if (totalNo > pageSize) {
//取模等于0,说明每页数据记录数一致,如果不等于0,说明最后一页数据数少
int pageIndex = totalNo % pageSize == 0 ? totalNo / pageSize : totalNo / pageSize + 1;
for (int i = 0; i <= pageIndex - 1; i++) {
int startLineIndex = i * pageSize;
int maxLine = (i + 1) * pageSize;
maxLine = maxLine > totalNo ? totalNo : maxLine;
System.out.println("startLindInde" + startLineIndex+"\t maxLine" + maxLine+"\t pageSize" + pageSize+"\t page"+i);
System.out.println(strContext.substring(startLineIndex, maxLine));
arrayList.add(strContext.substring(startLineIndex, maxLine));
}
}