0

hello all
i have a jap project.in which i have a lot of log(txt) files.what i want to do is searching a particular number in all log files and cut some fields of lines containing that number and show them as table in jsp page.

currently i am using shell scripting for searching and cut fields.but it is taking too much time to search and show data in jsp page.Can ANY ONE please help me

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by kingman123
0

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");

	}

Edited by Ezzaral: Added code tags. Please use them to format any code that you post.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.