posted 15 years ago
If that's the full extent of the code, there's no reason to prefer (2). (1) is perfectly fine.
If, on the other hand, you were going to write to the file a number of times -- especially many short writes like a list of a thousand names or something like that -- then using the BufferedWriter will be more efficient. The BufferedWriter will save up many of the little writes and send only large chunks of data to the FileWriter. Writing one large chunk to a file is more efficient than many small ones because each call to FileWriter.write() involves a call to the operating system, and those are slow.