StringHelper { public static String[] split(String s) { if (isEmpty(s)) { return new String[0]; } return s.split(",|;|:"); }  static String appendSlant(String url); static byte[] getBytes(String s); static String getString(byte[] bytes); static String[] mergeArray(String[] a, String[] b); static String[] emptyArray(); static String emptyString(); static boolean isEmpty(String s); static boolean isEmpty(String[] s); static String[] checkEmpty(String[] s); static String isEmpty(String value, String defaultValue); static String[] split(String s); static List<String> splitToList(String s);  }
@Test public void split() throws UnsupportedEncodingException { String s1 = "1,2,3,4"; String s2 = "1;2;3;4"; String s3 = "1:2:3:4"; String[] array = new String[]{"1","2","3","4"}; Assert.assertEquals(0, StringHelper.split(null).length); Assert.assertEquals(0, StringHelper.split(StringHelper.emptyString()).length); Assert.assertArrayEquals(array, StringHelper.split(s1)); Assert.assertArrayEquals(array, StringHelper.split(s2)); Assert.assertArrayEquals(array, StringHelper.split(s3)); List<String> list = Arrays.asList(array); List<String> l1 = StringHelper.splitToList(s1); List<String> l2 = StringHelper.splitToList(s2); List<String> l3 = StringHelper.splitToList(s3); for (int i = 0;i < list.size(); i++) { Assert.assertEquals(list.get(i), l1.get(i)); Assert.assertEquals(list.get(i), l2.get(i)); Assert.assertEquals(list.get(i), l3.get(i)); } }