Does the read command check the size of the buffer when filling it with data or is there a chance that data is lost because buffer isn’t big enough? In other words, if there are ten bytes of data available to be read, will the server continue to store the remaining 2 bytes of data until the next read.
I’m just using 8 as an example here to over dramatise the situation.
InputStream stdout;
...
while(condition)
{
...
byte[] buffer = new byte[8];
int len = stdout.read(buffer);
}
No,
read()won’t lose any data just because you haven’t given it enough space for all the available bytes.It’s not clear what you mean by “the server” here, but the final two bytes of a 10 byte message would be available after the first read. (Or possible, the first
read()would only read the first six bytes, leaving four still to read, for example.)