Skip to content

Instantly share code, notes, and snippets.

@keyboardr
Last active December 19, 2015 23:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save keyboardr/6033986 to your computer and use it in GitHub Desktop.
Save keyboardr/6033986 to your computer and use it in GitHub Desktop.
Concat strings with a delimeter
public class Util {
public static String buildConcatString(String delimeter, String... strings) {
StringBuilder builder = new StringBuilder();
boolean isFirst = true;
for (String string : strings) {
if (TextUtils.isEmpty(string)) {
continue;
}
if (!isFirst) {
builder.append(delimeter);
}
isFirst = false;
builder.append(string);
}
return builder.toString();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment