Ik zit net de specs van de verschillende java.io.* classes eens in detail te bekijken, en zie dat java.io.InputStream altijd byte-voor-byte leest, zelfs als je read(byte[]) aanroept:
The read(b) method for class InputStream has the same effect as:
read(b, 0, b.length)
en
The read(b, off, len) method for class InputStream simply calls the method read() repeatedly. If the first such call results in an IOException, that exception is returned from the call to the read(b, off, len) method. If any subsequent call to read() results in a IOException, the exception is caught and treated as if it were end of file; the bytes read up to that point are stored into b and the number of bytes read before the exception occurred is returned. Subclasses are encouraged to provide a more efficient implementation of this method.
Ik zit met een paar apps met aardig wat socket overhead (na profilen), en vraag me na het lezen van dit statement af hoe sockets dan ooit snel kunnen werken onder Java? Ik was in de veronderstelling dat Java's InputStream.read(byte[]) ook daadwerkelijk meerdere bytes tegelijk (native) kon lezen.
The read(b) method for class InputStream has the same effect as:
read(b, 0, b.length)
en
The read(b, off, len) method for class InputStream simply calls the method read() repeatedly. If the first such call results in an IOException, that exception is returned from the call to the read(b, off, len) method. If any subsequent call to read() results in a IOException, the exception is caught and treated as if it were end of file; the bytes read up to that point are stored into b and the number of bytes read before the exception occurred is returned. Subclasses are encouraged to provide a more efficient implementation of this method.
Ik zit met een paar apps met aardig wat socket overhead (na profilen), en vraag me na het lezen van dit statement af hoe sockets dan ooit snel kunnen werken onder Java? Ik was in de veronderstelling dat Java's InputStream.read(byte[]) ook daadwerkelijk meerdere bytes tegelijk (native) kon lezen.