import java.util.ArrayList;
import java.util.List;
public class JsonTest {
public static void main(String[] args) { String str = "1234567890124564698797946532132132132156"; stringToList(str,7); } public static void stringToList(String str,int length){ List list = new ArrayList(); //按照该长度进行字符串的分割 //将输入的字符串分割为几份 int size = str.length()/length+1; System.out.println(size); for (int i = 0; i < size; i++) { if (i==size-1){ String substring = str.substring(i * length, str.length()); list.add(substring); }else { String substring = str.substring(i * length, (i + 1) * length); list.add(substring); } } System.out.println(list); }
}