Apache Commons Lang does indeed have a StringUtils.join method which will connect String
arrays together with a specified separator.
For example:
String[] s = new String[] {"a", "b", "c"};
String joined = StringUtils.join(s, ","); // "a,b,c"
However, I suspect that, as you mention, there must be some kind of conditional or substring processing in the actual implementation of the above mentioned method.
If I were to perform the String
joining and didn't have any other reasons to use Commons Lang, I would probably roll my own to reduce the number of dependencies to external libraries.