根据传入字符串和截取个数分割字符串
package date0419;public class Test01 {public static void main(String[] args) {String[] s=split("java4ever",2);for(int i=0;i<s.length;i++){System.out.print(s[i]+",");}}public static String[] split(String str, int chars) {String[] str1 = null;int len = (str.length() + chars - 1) / chars;str1 = new String[len];for (int i = 0; i < len; i++) {if (i < len - 1) {str1[i] = str.substring(i * chars, chars * (i + 1));} else {str1[i] = str.substring(i * chars);}}return str1;}}