I have stream of bytes, which I got by using getInputStream() method from socket. How to read 1 or 2 bytes from this stream with offset n and convert them to integer.
Thanks!
I have stream of bytes, which I got by using getInputStream() method from socket.
Share
You can try to use
DataInputStreamwhich allows you to read primitive types:UPD: More specifically, you could use the code of
readInt()method:UPD-2: If you read 2-bytes array and sure, that it contains full integer number, try this:
UPD-3: Pff, full method for doing it: