N
nooneinparticular314159
I'm reading some bytes sent over the network from a bytebuffer that
I'm using with Java.NIO. The last time I tried this, I was reading
text data, so I created a charbuffer view of the bytebuffer and
appended to a string until my string was long enough to contain the
data that I wanted to manipulate. This time, I want to get bytes out,
and I'm being sent bytes. Great! Except what I can't figure out is
how to tell if enough bytes have arrived yet.
ie. Let's say that I really want 100 bytes of data. Until 100 bytes
arrive, I can't do anything useful with the data. How can I test to
see if 100 new bytes are currently available for reading in the
bytebuffer? What happens if, say, only 60 bytes have arrived? Is
there a way to test the length of the newly arrived bytes and not read
from the buffer until 100 show up?
Thanks!
I'm using with Java.NIO. The last time I tried this, I was reading
text data, so I created a charbuffer view of the bytebuffer and
appended to a string until my string was long enough to contain the
data that I wanted to manipulate. This time, I want to get bytes out,
and I'm being sent bytes. Great! Except what I can't figure out is
how to tell if enough bytes have arrived yet.
ie. Let's say that I really want 100 bytes of data. Until 100 bytes
arrive, I can't do anything useful with the data. How can I test to
see if 100 new bytes are currently available for reading in the
bytebuffer? What happens if, say, only 60 bytes have arrived? Is
there a way to test the length of the newly arrived bytes and not read
from the buffer until 100 show up?
Thanks!