Skip to content

Commit

Permalink
Add utility to join objects as a string
Browse files Browse the repository at this point in the history
  • Loading branch information
gschueler committed Apr 15, 2011
1 parent 4c57098 commit 5580cd4
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions core/src/java/com/dtolabs/rundeck/core/utils/StringArrayUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,23 @@ public static String[] subtract(final String[] input, final String[] list) {
return (String[]) difference.toArray(new String[difference.size()]);
}

/**
* Format an array of objects as a string separated by a delimiter by calling toString on each object
*
* @param input List to format
* @param delim delimiter string to insert between elements
* @return formatted string
*/
public static String asString(final Object[] input, final String delim) {
final StringBuffer sb = new StringBuffer();
for (int i = 0 ; i < input.length ; i++) {
if (i > 0) {
sb.append(delim);
}
sb.append(input[i].toString());
}
return sb.toString();
}
/**
* Format a string array
*
Expand Down

0 comments on commit 5580cd4

Please sign in to comment.