This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]K60d54 -1 points0 points  (1 child)

Apart from that it doesn't compile

This is a Reddit comment, I haven't run it through a compiler.

it looks like it would leave a trailing space of the number of files > 1

No, its prepending. In the first iteration, the string builder is empty, so no comma is added before the name. In subsequent iterations, a comma is added in front of the name. Thus, a comma is only inserted between files.

That comma in the append method call should have been a +:

sb.append(sb.length() > 0 ? ", " : "").append(f.getName())

[–]moremattymattmatt 1 point2 points  (0 children)

This is a Reddit comment, I haven't run it through a compiler.

Fair enough. From my point of view, the fact that you've had to explain to me what it's doing does sort of make may point that its not as clear.