First lambda, formatter for StringJoiner?
paul.sandoz at oracle.com
Mon Jun 24 01:38:59 PDT 2013
You can use a map operation to format elements to a String before collecting.
BTW the latest source code renamed toStringJoiner to joining and now hides the use of the StringJoiner class.
On Jun 21, 2013, at 9:39 PM, Brenden Towey <brendentowey at gmail.com> wrote:
> Hi all,
> I played around with the Java 8 early access build for the first time
> last week. Overall it was fun and I learned a bit. One thing struck me
> looking at the Collectors.toStringJoiner() method:
> StringJoiner is pretty neat but it could use a formatter string, like
> java.util.Formatter. It's a common pattern to need to format objects as
> one collects them into a string. For example, a stream of bytes will
> often need to be formatted as two character hexidecimal strings, rather
> than the default decimal representation.
> Adding a formatter string both to StringJoiner's ctor as well as to the
> static convenience method in Collectors would be a big boon to Java
> programmers everywhere.
> OK, that's my 2 cents! Good luck folks.
More information about the lambda-dev