public static void main(String[] args) {
Long l=System.currentTimeMillis();
String t[] =mySplit("1234$2344556$2213$wwer$2qww","$2");
System.out.println(Arrays.toString(t));
Long l2=System.currentTimeMillis();
System.out.println(l2-l);
}
public static String[] mySplit(String text,String separat){
int off = 0;
int len = 0;
ArrayList<String> list = new ArrayList<>();
int next =0;
do{
next = text.indexOf(separat,off);
if(next==-1){
list.add(text.substring(off));
String[] result = new String[len];
return result=list.toArray(result);
}
list.add(text.substring(off, next));
off = next + 1;
}while(next!= -1) ;
return null ;
}
原文:https://www.cnblogs.com/Java93/p/14543395.html