I am implementing a facility that uses generic reading interface. I am using java.lang.Readable interface which uses CharBuffer to write out the data to.
What it doesn’t say is whether the read call will block. It does however return amount of characters written in the buffer, but to me it can also indicate that the buffer didn’t have enough space left for the entire waiting input to be written, so only part of it was written instead. But what happens if the buffer has plenty of space, but no input (or fewer character than buffer can hold) is available? Will read return zero (or a small integer number) or will it block?
Yes, it blocks. After operation is completed this method returns the number of char values added to the buffer, or -1 if this source of characters is at its end.