Here you can find the source of splitString(String str, int length)
public static List<String> splitString(String str, int length)
//package com.java2s; //License from project: Apache License import java.util.ArrayList; import java.util.List; public class Main { public static List<String> splitString(String str, int length) { List<String> list = new ArrayList<String>(); for (int i = 0; i < str.length(); i += length) { int endIndex = i + length; if (endIndex <= str.length()) { list.add(str.substring(i, i + length)); } else { list.add(str.substring(i, str.length() - 1)); }/*from w w w . j a v a2 s .co m*/ } return list; } }