I have a piece of test equipment, from which I can read data using an InputStream
, which intersperses bytes and characters (organized into lines), e.g.:
TEST1
TEST2
500
{500 binary bytes follows here}
TEST3
TEST4
600
{600 binary bytes follows here}
I'd like to use BufferedReader so I can read a line at a time, but then switch to InputStream so I can read the binary bytes. But this neither seems to work nor seems like a good idea.
How can I do this? I can't get bytes from a BufferedReader, and if I use a BufferedReader on top of an InputStream, it seems like the BufferedReader "owns" the InputStream.
Edit: the alternative, just using an InputStream everywhere and having to convert bytes->characters and look for newlines, seems like it would definitely work but would also be a real pain.