I'm reading a DataInput.
I have a variable number of bytes stored at the end of an input stream (may be in a file, may come from a socket, etc.).
I need EOF to tell me when I reach the end AND I need the count of the actual number of bytes of data.
This gets the data:
But I don't know how many bytes actually read. Can anyone think of a way to get the count, short of reading one byte at a time and counting them?Code:byte[] data = new byte[WAY_TOO_MANY_BYTES]; try { in.readFully(data); } catch (EOF e) { // ignore }


Reply With Quote


Bookmarks