Skip to content

Commit

Permalink
user defined to string separator
Browse files Browse the repository at this point in the history
  • Loading branch information
REAndroid committed Sep 19, 2023
1 parent aa78cba commit b7803b8
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/main/java/com/reandroid/utils/StringsUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
Expand All @@ -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 ++;
Expand Down

0 comments on commit b7803b8

Please sign in to comment.