I have array of Strings for example:
String[] arr = {"one", "two", "three"};
Is possible with Guava Joiner get string like this:
"<one>, <two>, <three>"
where , is separator and < > are prefix and suffix for every element.
Thanks.
I have array of Strings for example:
String[] arr = {"one", "two", "three"};
Is possible with Guava Joiner get string like this:
"<one>, <two>, <three>"
where , is separator and < > are prefix and suffix for every element.
Thanks.
You can use also Collectors.joining() like below:
String[] arr = {"one", "two", "three"};
String joined = Stream.of(arr).collect(Collectors.joining(">, <", "<", ">"));
System.out.println(joined);
Use a Joiner with the end of one and the start of the next:
Joiner.on(">, <")
And then just put a < on the start, and > on the end.
"<" + Joiner.on(">, <").join(arr) + ">"
You might want to handle the empty array case, to distinguish this from {""}:
(arr.length > 0) ? ("<" + Joiner.on(">, <").join(arr) + ">") : ""