I’m attempting to use an AsyncTask to read from a file at regular intervals. The file has a hard-coded “EOL” type separator between each interval of lines I want to read. My current implementation involves an AsyncTask reading the first interval of lines using a BufferedReader until it approaches the EOL marker, then does some updating of the UI with publishProgress(), waits a period of time, and should then move on to the next interval of text.
My question is the following: how can I accomplish moving on to the next interval of text while using an AsyncTask? It seems like I have to keep calling new() on the BufferedReader for each interval, which in turn resets my position in the file. Are there any alternate libraries I can use? Note that I need to keep the AsyncTask, as I am attempting to simulate the data being streamed in from a live source every X seconds.
I can provide some code if necessary, but this is mainly a high-level design question.
Keep a long variable that holds your byte count and use the skip(long bytecount) method.
Alternatively subclass AsyncTask and give it a static BufferedReader as a member field