Yet Another Cleaner Way To Construct CSV String in Java

Accidentally found this util class while reading an ebook, and think it worth sharing since myself always found this a tedious code especially prefix and suffix the string.

We used to construct CSV string as below:

With new StringJoiner util in Java 1.8, we can do it in a cleaner way.

The constructor also allow us to prefix and suffix the string.

 

 

dicksonkho

 

Leave a Reply

Your email address will not be published. Required fields are marked *