I recently encountered an idiom I haven\'t seen before: string assembly by StringWriter and PrintWriter. I mean, I know how to use them, but I\'ve always used StringBuilder
Stylistically, the StringBuilder approach is cleaner. It is fewer lines of code and is using a class that was specifically designed for the purpose of building strings.
The other consideration is which is more efficient. The best way to answer that would be to benchmark the two alternatives. But there are some clear pointers that StringBuilder should be faster. For a start, a StringWriter uses a StringBuilder StringBuffer under the hood to hold the characters written to the "stream".