[...] how to search in reveres order (reverse search) in java?
I assume that you are looking for a line starting at the end.
For this task you can use String.lastIndexOf(str) . This will find the last substring index str . If you want to continue searching from this point, you can add a second fromIndex argument.
Exactly the same methods exist for StringBuilder .
source share