0

I have a set of self deserializing classes that take data from a socket. The serialized data format provides length information in a header preceeding the payload. In case the payload is not deseriablizable I would like to skip the entire block using the length information in the aforementioned header.
However, in order to do so I would need to know how much data has already been read from the socket. I thought that BufferedInputStream would allow me to do that using mark() before deserialization of the payload starts and then use pos and markpos to determine the amount of data read but realized that those two variables or protected.

Is there a better way to get access to this information other than sub-classing BufferedInputStream?

pinckerman
  • 4,115
  • 6
  • 33
  • 42

1 Answers1

1

You can mark() BIS before deserialisation, and then call reset().

There are public.

Then you can skip any number of bytes, by skip method.

documentation

Seagull
  • 13,484
  • 2
  • 33
  • 45