in build.gradle add Guava
compile group: 'com.google.guava', name: 'guava', version: '27.0-jre'
and then
public static List<String> splitByComma(String str) {
Iterable<String> split = Splitter.on(",")
.omitEmptyStrings()
.trimResults()
.split(str);
return Lists.newArrayList(split);
}
public static String joinWithComma(Set<String> words) {
return Joiner.on(", ").skipNulls().join(words);
}
enjoy :)