Joins a string array into a String. @param delim the delimiter to insert between values @param array the array to join @param quoteStringsWithSpaces whether to surround strings that contain spaces with quotes or not @return the string elements joined by the delimiter
(final String delim, final String[] array, final boolean quoteStringsWithSpaces)
| 288 | * @return the string elements joined by the delimiter |
| 289 | */ |
| 290 | public static String join(final String delim, final String[] array, final boolean quoteStringsWithSpaces) { |
| 291 | final StringBuilder sb = new StringBuilder(); |
| 292 | for (int i = 0; i < array.length; ++i) { |
| 293 | if (i != 0 && delim != null) { |
| 294 | sb.append(delim); |
| 295 | } |
| 296 | sb.append(quoteStringsWithSpaces ? smartQuote(array[i]) : array[i]); |
| 297 | } |
| 298 | return sb.toString(); |
| 299 | } |
| 300 | |
| 301 | /** |
| 302 | * Joins a string array into a String. |