Thanks Rob for your quick reply,
Here pattern is in more than one line
So i cannot go line by line.
To search the pattern(more than a line) i have to load entire file in memory and have to do search for the pattern,due to this getting heap memory error.
What will be the best way to search the pattern in the above scenario?
Thanks