Advertisement

05.21.2008 at 07:56PM PDT, ID: 23423155
[x]
Attachment Details

Is BufferedReader able to handle 100,000 lines of HTML source code?

Asked by mawingho in Java Programming Language

Below is one of the function in my Java program. This function fetches the HTML source code and process it then return it. However, the HTML source is very large, it contains more than 100,000 html table, is BufferedReader able to handle it?
Thanks!Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
public void fetch_device_data(String device_name){
 
        String s = null;
		String data = null;
 
        try {
            
            Process p = Runtime.getRuntime().exec("wget -O - http://user:pass@61.10.0.168/cgi-bin/chkdocoper_chid.cgi?"+device_name);
            
            BufferedReader stdInput = new BufferedReader(new 
                 InputStreamReader(p.getInputStream()));
			
            while ((s = stdInput.readLine()) != null) {
				data += s;
            }
        }
        catch (IOException e) {
            write_log("exception happened - here's what I know: ");
            e.printStackTrace();
            System.exit(-1);
        }
		
		if(data != null){
			int first_pos = data.indexOf("<table");
			int last_pos = data.lastIndexOf("</table>");
			
			if(first_pos != -1 && last_pos != -1){
				data = data.substring(first_pos, last_pos + 8);
				data = data.replaceAll("<[/]{0,1}table[^>]*>", "");		//Remove all table tags
				data = data.replaceAll("<(tr|td)[^>]*>", "<$1>");		//Remove all the attributes in tr and td tags
				data = data.replaceAll("<([/]{0,1}[a-z]*)>[ ]*", "<$1>").trim();
				data = data.replaceAll("</(td|tr)>", "");				//Remove all ending tr and td tags
				data = data.replaceFirst("<tr>", "");				//Remove the first tr tag, which is not required, during split
				
				String temp[] = data.split("<tr>");
				result = new String[temp.length][];
				for(int i=0; i<temp.length; i++){
					temp[i] = temp[i].replaceFirst("<td>", "");
					result[i] = temp[i].split("<td>");
				}
			}
		}
    }
 
Loading Advertisement...
 
[+][-]05.21.2008 at 08:12PM PDT, ID: 21620610

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.21.2008 at 08:19PM PDT, ID: 21620648

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.21.2008 at 08:23PM PDT, ID: 21620666

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.21.2008 at 08:27PM PDT, ID: 21620687

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.21.2008 at 10:39PM PDT, ID: 21621183

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Java Programming Language
Sign Up Now!
Solution Provided By: humanonomics
Participating Experts: 3
Solution Grade: A
 
 
[+][-]05.22.2008 at 05:18AM PDT, ID: 21623024

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628