CSV to HTML translation: Difference between revisions
Content deleted Content added
Thundergnat (talk | contribs) Rename Perl 6 -> Raku, alphabetize, minor clean-up |
→{{header|Java}}: Add version with streaming/StringJoiner |
||
Line 2,342:
=={{header|Java}}==
'''Simple solution without escaping for Java v8+'''
<lang java>String csv = "...";
// Use Collectors.joining(...) for streaming, otherwise StringJoiner
StringBuilder html = new StringBuilder("<table>\n");
Collector collector = Collectors.joining("</td><td>", " <tr><td>", "</td></tr>\n");
for (String row : csv.split("\n") ) {
html.append(Arrays.stream(row.split(",")).collect(collector));
}
html.append("</table>\n");</lang>
'''Solution including simple and extra credit version'''
|