/** * Creates a new copy of the string with the separator backslash escaped. * @see #join */ public static String escapeTextWithSeparator(String item, char separator) { StringBuilder sb = new StringBuilder(item.length() * 2); appendEscapedTextToBuilder(sb, item, separator); return sb.toString(); }
/** * Creates a new copy of the string with the separator backslash escaped. * @see #join */ public static String escapeTextWithSeparator(String item, char separator) { StringBuilder sb = new StringBuilder(item.length() * 2); appendEscapedTextToBuilder(sb, item, separator); return sb.toString(); }
/** * Creates a backslash escaped string, joining all the items. * @see #escapeTextWithSeparator */ public static String join(Collection<?> items, char separator) { if (items == null) return ""; StringBuilder sb = new StringBuilder(items.size() << 3); boolean first=true; for (Object o : items) { String item = String.valueOf(o); if (first) { first = false; } else { sb.append(separator); } appendEscapedTextToBuilder(sb, item, separator); } return sb.toString(); }
/** * Creates a backslash escaped string, joining all the items. * @see #escapeTextWithSeparator */ public static String join(List<?> items, char separator) { StringBuilder sb = new StringBuilder(items.size() << 3); boolean first=true; for (Object o : items) { String item = o.toString(); if (first) { first = false; } else { sb.append(separator); } appendEscapedTextToBuilder(sb, item, separator); } return sb.toString(); }