You are right. Here is how write()
method of BufferedWriter
looks:
public void write(int c) throws IOException {
synchronized (lock) {
ensureOpen();
if (nextChar >= nChars)
flushBuffer();
cb[nextChar++] = (char) c;
}
}
As you can see it indeed checks whether the buffer is full (if (nextChar >= nChars)
) and flushes the buffer. Then it adds new character to buffer (cb[nextChar++] = (char) c;
).