From b7803b8a31d0616960cca88e31abf26d26b15929 Mon Sep 17 00:00:00 2001 From: REAndroid Date: Tue, 19 Sep 2023 20:31:07 +0200 Subject: [PATCH] user defined to string separator --- src/main/java/com/reandroid/utils/StringsUtil.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/reandroid/utils/StringsUtil.java b/src/main/java/com/reandroid/utils/StringsUtil.java index f883147a5..8491c2c98 100644 --- a/src/main/java/com/reandroid/utils/StringsUtil.java +++ b/src/main/java/com/reandroid/utils/StringsUtil.java @@ -120,6 +120,9 @@ public static String toString(Collection collection, int max) { return toString(collection.iterator(), max, collection.size()); } public static String toString(Iterator iterator, int max, int size) { + return toString(", ", iterator, max, size); + } + public static String toString(String separator, Iterator iterator, int max, int size) { if(iterator == null){ return "null"; } @@ -130,7 +133,7 @@ public static String toString(Iterator iterator, int max, int size) { StringBuilder elements = new StringBuilder(); while (iterator.hasNext() && (max < 0 || count < max)){ if(count != 0){ - elements.append(", "); + elements.append(separator); } elements.append(iterator.next()); count ++;