I am using a seekable InputStream which returns the stream to me at a specific position. The underlying data in the stream is encoded with UTF-8. I want to open this stream using inputStreamReader and read one character at a time.
Here is my code snippet
inputStream.seek(position-1);
InputStreamReader reader = new InputStreamReader(inputStream, "UTF-8");
The problem is that if position-1 could be pointing to the middle of a multi-byte UTF-8 sequence. How can I detect that make sure it starts from a new UTF-8 encoded sequence? Thanks in advance.