I am trying to write a Java program to print preceding and succeeding of a known word in a text file.
For example
Suppose I know a word "like"
a text file contains text like below
Sam like chocolate and other stuff
I need to print Sam
and chocolate
which are preceding and succeeding the known word like
.
can anybody give a Java program for the above task.