Contents
Sometimes you have a list that needs to become a string. For example
List<Integer> number = Arrays.asList(1, 2, 3, 4, 5);
String text = StringUtils.join(number, ", ");
will produce
1, 2, 3, 4, 5
by invoking the .toString() on each object in the collection.
if .toString() isn't enough, you can pass in a lambda to do the extra transformation as well. For example:
List<Integer> number = Arrays.asList(1, 2, 3, 4, 5);
String text = StringUtils.join(number, ", ", n -> StringUtils.padNumber(n, 3));
will Produce
001, 002, 003, 004, 005