public static void main(String[] args) { String s1 = "00AM0002[{\"mid\":6666,\"userid\":73300,\"fromid\":7329889,\"message\":\"上海滩\",\"mtype\":\"20101\",\"sendstatus\":\"00\",\"createtimestamp\":\"2014-02-10 17:20:35.0\",\"userLogin\":{\"userId\":7329889,\"checkStatus\":\"01\",\"mp\":\"15300000007\",\"webName\":\"15300000007\",\"userType\":\"21\",\"nickName\":\"10号\",\"useclient\":\"ui\"}}];"; String s = "00BM0002[{\"mid\":2069,\"userid\":73300,\"fromid\":7329889,\"message\":\"上海滩\",\"mtype\":\"20101\",\"sendstatus\":\"00\",\"createtimestamp\":\"2014-02-10 17:20:35.0\",\"userLogin\":{\"userId\":7329889,\"checkStatus\":\"01\",\"mp\":\"15300000007\",\"webName\":\"15300000007\",\"userType\":\"21\",\"nickName\":\"10号\",\"useclient\":\"ui\"}}];"; s += s + s1; String[] aa = s.split("00BM0002|00AM0002"); System.out.println("aa.length = " + aa.length); for (int i = 0 ; i < aa.length ; i++ ) { System.out.println("--"+aa[i]); String json = aa[i].substring(0, aa[i].lastIndexOf("]") + 1); System.out.println("--" + json); } }
原文:http://blog.csdn.net/wangyuexing_blog/article/details/19044779