StringUtils { public static String collectionToString(Collection list) { return collectionToString(list, ", "); } private  StringUtils(); static String writeMatrix(DoubleMatrix2D mat); static String writeMatrix(IntMatrix2D mat); static String writeMatrix(DoubleMatrix1D mat); static String writeMatrix(IntMatrix1D mat); static DoubleMatrix2D readMatrix(String s); static IntMatrix2D readIntMatrix(String s); static String[] arrayOf(String... values); static int[] find(String[] array, String value, Constants.SearchType searchType); static String getLineSeparator(); static String join(String[] array, String separator); static String join(Collection<String> collection, String separator); static String mapToString(Map map); static String mapToString(Map map, String keyValueSeparator, String entrySeparator); static String collectionToString(Collection list); static String collectionToString(Collection list, String entrySeparator); static void saveToFile(String text, File file); static void saveToFile(String text, File file, boolean append); static String secondsToYearsDaysHoursMinutesSeconds(double seconds); static String[] select(String[] array, int[] indexes); static String[] split(String string); static String[] split(String string, String separators); static Map<String, String> stringToMap(String string); static Map<String, String> stringToMap(String string, String keyValueSeparator, String entrySeparator); static String[] toArray(Collection list); static boolean[] toBooleanArray(Collection<String> collection); static boolean[] toBooleanArray(Collection<String> collection, boolean valueForNull); static boolean[] toBooleanArray(String[] array); static boolean[] toBooleanArray(String[] array, boolean valueForNull); static List<Boolean> toBooleanList(String[] array); static List<Boolean> toBooleanList(String[] array, boolean valueForNull); static Map<A, Boolean> toBooleanMap(Map<A, String> map); static Map<A, Boolean> toBooleanMap(Map<A, String> map, boolean valueForNull); static double[] toDoubleArray(Collection<String> collection); static double[] toDoubleArray(Collection<String> collection, double valueForNull); static double[] toDoubleArray(String[] array); static double[] toDoubleArray(String[] array, double valueForNull); static List<Double> toDoubleList(String[] array); static List<Double> toDoubleList(String[] array, double valueForNull); static Map<A, Double> toDoubleMap(Map<A, String> map); static Map<A, Double> toDoubleMap(Map<A, String> map, double valueForNull); static int[] toIntArray(Collection<String> collection); static int[] toIntArray(Collection<String> collection, int valueForNull); static int[] toIntArray(String[] array); static int[] toIntArray(String[] array, int valueForNull); static Map<A, Integer> toIntegerMap(Map<A, String> map); static Map<A, Integer> toIntegerMap(Map<A, String> map, int valueForNull); static List<String> toList(String[] array); static long[] toLongArray(Collection<String> collection); static long[] toLongArray(Collection<String> collection, long valueForNull); static long[] toLongArray(String[] array); static long[] toLongArray(String[] array, long valueForNull); static List<Long> toLongList(String[] array); static List<Long> toLongList(String[] array, long valueForNull); static Map<A, Long> toLongMap(Map<A, String> map); static Map<A, Long> toLongMap(Map<A, String> map, long valueForNull); static Map<String, String> toMap(String string, String keyValueSeparator, String entrySeparator); static String createEscapedString_asStringList(Collection<String> vals); static List<String> readEscapedString_asStringList(String val , List<String> defaultValue); static String escapedStringToWrite(String s); static String unescapedStringRead(String s);  }
@Test public void testListToStringDefaultSeparator() { final String string = StringUtils.collectionToString(testList); Assert.assertEquals("test1, test2, test3", string); }
@Test public void testListToStringSpecificSeparator() { final String string = StringUtils.collectionToString(testList, "; "); Assert.assertEquals("test1; test2; test3", string); }