Writing with OutputStreamWriter: line by line vs all at once
===

Which runs faster: using OutputStreamWriter.write() for each string to be written, or using StringBuilder to create one large string, then using write() once? Please explain why.

Here's using write() many times:

    writer.write("Registered Players:\n");
    while (it.hasNext()) {
        int playerID = (Integer) it.next();
        Player player = playerRegistry.get(playerID);

        writer.write(playerID+": "+player.getPlayerName()+"\n");
    }

And here's with StringBuilder:

    builder.append("Registered Players:\n");
    while (it.hasNext()) {
        int playerID = (Integer) it.next();
        Player player = playerRegistry.get(playerID);

        builder.append(playerID+": "+player.getPlayerName()+"\n");
    }
    writer.write(builder.toString());