Skip to content

Instantly share code, notes, and snippets.

@herusdianto
Created June 10, 2015 08:21
Show Gist options
  • Save herusdianto/2e70fb647c0b3884dc7f to your computer and use it in GitHub Desktop.
Save herusdianto/2e70fb647c0b3884dc7f to your computer and use it in GitHub Desktop.
Groovy Implode Array
def implode(ArrayList inputArray, String glueString)
{
/** Output variable */
String output = "";
if (inputArray.size() > 0)
{
StringBuilder sb = new StringBuilder();
sb.append(inputArray[0]);
for (int i = 1; i < inputArray.size(); i++)
{
sb.append(glueString);
sb.append(inputArray[i]);
}
output = sb.toString();
}
return output;
}
// reference: https://imwill.com/implode-string-array-java/#.VXfzZ62lyko
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment