neuraminidase7
neuraminidase7

Reputation: 486

OutputStreamWriter Writing Big Files

I'm using this to write a big file:

output = new OutputStreamWriter(new FileOutputStream(fileName), o.charset); 

But it is only write 8192 bytes. How to set this limit?

Upvotes: 1

Views: 1761

Answers (1)

Joni
Joni

Reputation: 111219

You have to close the writer when you have finished writing.

OutputStreamWriter has an internal buffer of 8kb that makes converting character data to bytes more efficient. When the buffer fills it is automatically flushed to the underlaying output stream. The buffer is also flushed when you close the stream. If you don't flush or close the stream the data stays in the memory buffer and is never written to disk.

In general, you should always close all input and output streams, readers and writers that you open.

Upvotes: 1

Related Questions