I have a class that is responsible for reading a TXT file part by piece and returning a result according to that part.
This result will be used by another class. That is, I open the txt read until a certain part and make a return to another class. But when I call this class it reads again. I want to continue from where I left off in txt and not have to read it all over again.
Example:
I have the following text file:
"Hi, how are you? I would like to know your name
My name is Joao "
I want my reading class to read this part:
"Hi, how's it going?"
Then when you call her again she will start reading from here:
"I'd like to know your name
My name is Joao "
NOTE: This was just a hypothetical example.
Please help me. my code for reading is this:
FileReader in = null;
try {
in = new FileReader(dir);
BufferedReader br = new BufferedReader(in);
String line;
int lineNum = 1;
while ((line = br.readLine()) != null) {
verifyLine(line,lineNum);
lineNum++;
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
The verify function takes the line and le only the parts I want. But when I give the return I come back from the beginning. In other words, if I keep within this class I can read the way I want. But if I return to another class, I already have problems.