| return sb.toString().trim(); |
There is a .trim() call, but this only trims whitespace. If the separator is non-whitespace (e.g. underscore, dash, period, bar, etc.), then trim doesn't work.
Also, Apache Commons has a StringUtils that works very nicely. Perhaps we want to remove this in favor of that.