Can you please tell me how to search in reveres order (backward search) in Java?
I need to do same for searching in HTML file as text.
Can you please tell me how to search in reveres order (backward search) in Java?
I need to do same for searching in HTML file as text.
[...] how to search in reveres order (backward search) in java?
I assume you mean search for a string starting from the end.
For this task you can use String.lastIndexOf(str)
. This will locate the last index of the substring str
. If you want to keep searching from that point, you can add a second fromIndex
argument.
The exact same methods exist for StringBuilder
as well.
if want to search in file 1. Open file in random access mode. 2. go to end of file. 3. then search in string.