Based on this question I would like to ask the following. Assuming blocking I/O and I have a piece of code like the following:
byte[] data = new byte[10];
someInputStream.read(data)
This code snippet is going to block in the read
call until it has some bytes to read. I'm familiar that read
might actually read less bytes and the number of bytes read is going to be returned by the read
method.
My question is this. Assume I have:
byte[] data = new byte[10];
if (someInputeStream.available() >= 10) {
someInputStream.read(data); // ***
}
Is ***
line guaranteed to not block? Again, I'm aware that this read might still read less than 10 bytes.