Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OutputStreamWriter internal buffer size

Tags:

java

java-io

I want to create an unbuffered OutputStreamWriter. The docs (Java 7) say

The resulting bytes are accumulated in a buffer before being written to the underlying output stream. The size of this buffer may be specified, but by default it is large enough for most purposes.

"The size of this buffer may be specified"... how?

(Edit: this was an old bug in the documentation; fixed in Java 9)

like image 429
leonbloy Avatar asked Dec 17 '14 18:12

leonbloy


1 Answers

Well, it seems that there is no way to tweak the buffer size. It was once possible to set the size in the constructor... in Java 1.1!

The constructor dissapeared in Java 1.2 (1998) and apparently they forgot to update the documentation.

(It looks strange to me that this documentation bug has gone unnoticed so many years - and it also looks strange that I have no way to turn off the buffering.)

Update: still the same in Java 8

Update 2: acknowledged as doc bug, finally removed in Java 9 docs

like image 159
leonbloy Avatar answered Oct 21 '22 08:10

leonbloy