标签:class blog java tar string art
public static String[] split(String str, String limit) { List<String> result = new ArrayList<String>(); char[] chars = limit.toCharArray(); int length = str.length(); int slice = chars.length - 1; int match = 0, start = 0, count = 1; for (int i = 0; i < length; i++) { char c = str.charAt(i); if (c == chars[match]) { match++; if (match == chars.length) { result.add(str.substring(start, i - slice)); start = i + 1; count++; match = 0; } } else { if (match != 0) match = (c == chars[0]) ? 1 : 0; } } result.add(str.substring(start, length)); return result.toArray(new String[count]); }
标签:class blog java tar string art
原文地址:http://www.cnblogs.com/rilley/p/3791233.html