user3362334
user3362334

Reputation: 2180

Why does FileWriter have a buffer?

I read that the difference between FileWriter and BufferedWriter is that FileWriter writes directly into a file(char by char), white BufferedReader uses a buffer. If so, why does FileWriter have a buffer? For example if I make a FileWriter object like this:

FileWriter writer = new FileWriter("f://test123.txt");

and, if I don't flush or close the writer in the end of the program, it would not write anything to a file. That means it alos uses a buffer. Please, explain?

Upvotes: 0

Views: 145

Answers (1)

user207421
user207421

Reputation: 311023

It doesn't have a buffer itself but it extends OutputStreamWriter, which does, in the form of a StreamEncoder.

Upvotes: 0

Related Questions