Java tip: String.format() might have an impact on your performance

When writing to a file in Java (8), it is quite usual to see the following:

try (final BufferedWriter writer = Files.newBufferedWriter(file, ...)) {
    for (final String line : lines) {
        writer.write(String.format("%s%n", line));
    }
}

However, replacing this with the following code lead to a 75% performance improvement in my case:

try (final BufferedWriter writer = Files.newBufferedWriter(file, ...)) {
    for (final String line : lines) {
        writer.write(line);
        writer.newLine();
    }
}