public static String[] split(String s, String token) {
		if (s == null)
			return null;
		if (token == null || s.length() == 0)
			return new String[] { s };
		int size = 0;
		String[] result = new String[4];
		while (s.length() > 0) {
			int index = s.indexOf(token);
			String splitOne = s;
			if (index > -1) {
				splitOne = s.substring(0, index);
				s = s.substring(index + token.length());
			} else {
				s = "";
			}
			if (size >= result.length) {
				String[] tmp = new String[result.length * 2];
				System.arraycopy(result, 0, tmp, 0, result.length);
				result = tmp;
			}
			if (splitOne.length() > 0) {
				result[size++] = splitOne;
			}
		}
		String[] tmp = result;
		result = new String[size];
		System.arraycopy(tmp, 0, result, 0, size);
		return result;
	}

  测试过,这个确实比官方的分割方法速度快,原始作者不晓的是谁了,因为隔好久了,现在总结才找到的代码

相关文章:

  • 2023-03-03
  • 2022-12-23
  • 2021-07-12
  • 2021-05-03
  • 2022-12-23
  • 2022-12-23
  • 2022-01-12
  • 2021-04-20
猜你喜欢
  • 2021-11-22
  • 2022-02-12
  • 2022-12-23
  • 2021-10-08
  • 2022-01-20
  • 2021-12-01
相关资源
相似解决方案