How to read current previous and next line from a text file
I have a script that reads current and next line from a text file and I am trying to modify this script so that it reads three lines (current prev next or current and next two lines ).
Any help is greatley appreciated.
//Construct the BufferedWriter object
File file = new File("C:/text.txt");
bufferedWriter = new BufferedWriter(new FileWriter(file));
reader = new BufferedReader(new InputStreamReader(in1));
for (String next, line = reader.readLine();
line != null; line = next)
{
next = reader.readLine();
System.out.println("Current line: " + line);
System.out.println("Next line: " + next);
}