Here is the file content :
line 1
line 2
line 3
line 4
line 5
Now I want to read the file in reverse order string as below
line 5
line 4
line 3
line 2
line 1
The code I use to read the file line by line is
try (Stream<String> steam = Files.lines(Paths.get("C:\\..\\..\\taxreport.txt")).skip(1)) {
steam.foreach(i->System.Out.Println(i));
}
catch (IOException ex) {
System.out.println(RED_BOLD + "File not Found !!");
}
The code read the file line by line in normal order. But I want to read the line in reverse order.
Can anyone let me know how can I read the line in reverse order.