I am using FileUtils from apache commons.io to search text between two strings in a file with the following code:
Pattern p = Pattern.compile(Pattern.quote(fromDate) + "(.*?)" + Pattern.quote(toDate));
try {
Matcher m = p.matcher(fileContent);
while (m.find()) {
System.out.println(m.group(1));
But there is an error it is giving output only when both the strings lie in same line, no output if strings are in at different lines? Here i am taking the content of whole file into a Sting Varibale "fileContent".