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

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

	}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.