@Test public void testSplitStringRandom() { String left = RandomStringUtils.randomAlphanumeric(40); String right = RandomStringUtils.randomAlphanumeric(40); for (int expectSliceNumber = 1; expectSliceNumber < 100; expectSliceNumber++) { String[] result = RangeSplitUtil.doAsciiStringSplit(left, right, expectSliceNumber); Assert.assertTrue(result.length - 1 == expectSliceNumber); String[] clonedResult = result.clone(); Assert.assertTrue(Arrays.toString(clonedResult).equals(Arrays.toString(result))); System.out.println(result); } }
public static String[] doAsciiStringSplit(String left, String right, int expectSliceNumber) { int radix = 128; BigInteger[] tempResult = doBigIntegerSplit(stringToBigInteger(left, radix), stringToBigInteger(right, radix), expectSliceNumber); String[] result = new String[tempResult.length]; result[0] = left; result[tempResult.length - 1] = right; for (int i = 1, len = tempResult.length - 1; i < len; i++) { result[i] = bigIntegerToString(tempResult[i], radix); } return result; }
RangeSplitUtil { public static String[] doAsciiStringSplit(String left, String right, int expectSliceNumber) { int radix = 128; BigInteger[] tempResult = doBigIntegerSplit(stringToBigInteger(left, radix), stringToBigInteger(right, radix), expectSliceNumber); String[] result = new String[tempResult.length]; result[0] = left; result[tempResult.length - 1] = right; for (int i = 1, len = tempResult.length - 1; i < len; i++) { result[i] = bigIntegerToString(tempResult[i], radix); } return result; } }
RangeSplitUtil { public static String[] doAsciiStringSplit(String left, String right, int expectSliceNumber) { int radix = 128; BigInteger[] tempResult = doBigIntegerSplit(stringToBigInteger(left, radix), stringToBigInteger(right, radix), expectSliceNumber); String[] result = new String[tempResult.length]; result[0] = left; result[tempResult.length - 1] = right; for (int i = 1, len = tempResult.length - 1; i < len; i++) { result[i] = bigIntegerToString(tempResult[i], radix); } return result; }  }
RangeSplitUtil { public static String[] doAsciiStringSplit(String left, String right, int expectSliceNumber) { int radix = 128; BigInteger[] tempResult = doBigIntegerSplit(stringToBigInteger(left, radix), stringToBigInteger(right, radix), expectSliceNumber); String[] result = new String[tempResult.length]; result[0] = left; result[tempResult.length - 1] = right; for (int i = 1, len = tempResult.length - 1; i < len; i++) { result[i] = bigIntegerToString(tempResult[i], radix); } return result; }  static String[] doAsciiStringSplit(String left, String right, int expectSliceNumber); static long[] doLongSplit(long left, long right, int expectSliceNumber); static BigInteger[] doBigIntegerSplit(BigInteger left, BigInteger right, int expectSliceNumber); static BigInteger stringToBigInteger(String aString, int radix); static Pair<Character, Character> getMinAndMaxCharacter(String aString); }
RangeSplitUtil { public static String[] doAsciiStringSplit(String left, String right, int expectSliceNumber) { int radix = 128; BigInteger[] tempResult = doBigIntegerSplit(stringToBigInteger(left, radix), stringToBigInteger(right, radix), expectSliceNumber); String[] result = new String[tempResult.length]; result[0] = left; result[tempResult.length - 1] = right; for (int i = 1, len = tempResult.length - 1; i < len; i++) { result[i] = bigIntegerToString(tempResult[i], radix); } return result; }  static String[] doAsciiStringSplit(String left, String right, int expectSliceNumber); static long[] doLongSplit(long left, long right, int expectSliceNumber); static BigInteger[] doBigIntegerSplit(BigInteger left, BigInteger right, int expectSliceNumber); static BigInteger stringToBigInteger(String aString, int radix); static Pair<Character, Character> getMinAndMaxCharacter(String aString);  }