1 public static List<String> getContentByList(String wholeString,Integer cutcount){
2
3 List<String> list = new ArrayList<String>();
4
5 int contentLength = wholeString.length();//数据长度
6
7 if (contentLength < cutcount) {
8 list.add(wholeString); //当数据长度小与指定的拆分长度,返回整个字符串
9 }
10 else{
11 String contentpart=""; //
12
13 int contentcutcount = 0;//定义段落被截取数
14 int begincut = 0;//截取段落的初始位置
15
16
17 int contentcutpart = 0; //判断截取的段落数
18
19 contentcutpart = contentLength / cutcount;
20
21 int contentparts = contentLength % cutcount;
22
23 if (contentparts == 0) {
24 contentcutcount = contentcutpart;
25 }else{
26 contentcutcount = contentcutpart +1;
27 }
28 //截取段落放入List中
29 for (int i = 1; i <= contentcutcount; i++) {
30 if (i !=contentcutcount) {
31
32 contentpart = wholeString.substring(begincut,cutcount*i );
33
34 }
35 else {
36 contentpart = wholeString.substring(begincut,contentLength);
37 }
38 begincut = cutcount *i;
39 list.add(contentpart);
40 }
41 }
42 return list;
43 }