Here you can find the source of concatenate(TreeSet
public static String concatenate(TreeSet<String> in)
//package com.java2s; //License from project: Apache License import java.util.TreeSet; public class Main { public static final char CONCATENATION_TOKEN = ' '; public static final char CONCATENATION_SUBSTITUTE = '_'; public static String concatenate(TreeSet<String> in) { StringBuffer buffer = new StringBuffer(); for (String element : in) { buffer.append(element.trim().replaceAll(CONCATENATION_TOKEN + "", CONCATENATION_SUBSTITUTE + "")); buffer.append(CONCATENATION_TOKEN); }// ww w .jav a 2 s. com String result = buffer.toString(); return result; } }