use of java8.util.StringJoiner in project streamsupport by stefan-zobel.
the class StringJoinerTest method noAddAndEmptyValue.
public void noAddAndEmptyValue() {
StringJoiner sj = new StringJoiner(DASH, "", "").setEmptyValue(EMPTY);
assertEquals(sj.toString(), EMPTY);
sj = new StringJoiner(DASH, "<..", "");
assertEquals(sj.toString(), "<..");
sj = new StringJoiner(DASH, "<..", "");
assertEquals(sj.toString(), "<..");
sj = new StringJoiner(DASH, "", "==>");
assertEquals(sj.toString(), "==>");
sj = new StringJoiner(DASH, "{", "}");
assertEquals(sj.toString(), "{}");
}
use of java8.util.StringJoiner in project streamsupport by stefan-zobel.
the class SortingNearlySortedPrimitive method arrayToString.
String arrayToString(int[] a) {
int[] l = Arrays.copyOfRange(a, 0, WIDTH + 2);
int[] r = Arrays.copyOfRange(a, a.length - (WIDTH + 2), a.length);
StringJoiner sj = new StringJoiner(",", "[", "]");
for (int i : l) {
sj.add(Integer.toString(i));
}
sj.add("...");
for (int i : r) {
sj.add(Integer.toString(i));
}
return sj.toString();
}
Aggregations