Readline from an input stream and nothing more.
I'm trying to achieve something quite specific and at the moment it looks like I'm going to have to code this myself from scratch, but I wanted to run it past people first to see if they know a way to do this from standard J2SE classes.
I need a method which will:
- Read a line of text (as a string) from an input stream
- Ideally using any supported charset (those obtainable as a Charset object) but at minimum UTF-8
- Return null or throw an exception if the input line is longer than a specified charicter length
- Read no more bytes from the input stream than are required for the line. This point is important for two reasons:
- The bytes following the bytes for the new line charicter may be raw binary and not conform to any charset.
- The InputStream may block indefanately if all the bytes for a line have already been read and the readline method then tries to read more
Obveously I've considdered a BufferedReader but this doesnt come close to requirement.
Thanks for your time.