Hey,
This would help you i guess. Correct me if i'm wrong
public static void Search(String filePath, String search, String ignoreCase)
throws IOException {
FileInputStream fstream = new FileInputStream(filePath);
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String str, str1;
boolean l_found = false;
int j = 1, k = 0;
while ((str = br.readLine()) != null) {
for (int i = 0; i < str.length(); i++) {
// Ignoring case of the string
if (ignoreCase == "Y") {
str1 = str.toLowerCase();
search = search.toLowerCase();
} else
str1 = str;
if (i + search.length() <= str.length()) {
if (search.equals(str1.substring(i, i + search.length()))) {
System.out.print("In Line : " + j);
System.out.println(" " + str);
l_found = true;
k++;
}
}
}
j = j + 1;
}
System.out.println("Total Match Found : " + k);
if (!l_found)
System.out.println(search + " String not found on the file");
}