Fixed typo in comment.
Use Integer.toString() instead of str + "". Documented setInteger().
Moved the separator into the disabled code path.

This gets rid of the double separator.
Use for each loop instead of ListIterator.
Extracted listAllPatterns() method into a new Util class.