My code reading a new file in every 5 sec. From that file I am fetching the status like "pass" and "fail" and writing into a html file. Everything is working fine but my problem is I want previous result also but it is not happening.
Suppose I am reading file1, then I am writing the result in html file and again I read another file2, the result is also writing into same html file. Can anybody please guide me how to do this? I have tried several time but it is not working. Below is the method where I want to implement the same. If needed I will put the whole code also.
public static String extractText(Reader reader) throws IOException
{
String s[]={
"RAP_45 1",
"RAP_50 1",
"RAP_75 1",
"RAP_PayAsYouGo 1",
"RAP_Refill_Coupon 1",
"RAP_UserPreferences_DefaultMarket 1",
"RAP_NonTransitional_PortIn 1",
"RAP_Transitional_PortIn 1",
"RAP_Activation_Simply_Prepaid_Mexico/Canada 1"
};
StringBuilder sb = new StringBuilder();
BufferedReader br = new BufferedReader(reader);
FileWriter writeReport = new FileWriter("C:\\Users\\jdutta\\files\\ResultSummary.html");
BufferedWriter bw = new BufferedWriter(writeReport);
String line;
bw.write("<html><Body font=\"14px/1.4 Georgia\" ><br><table border=\"2%\" width=\"50%\"><h3 >Summary:</h3><tr bgcolor=\"black\">");
bw.write("<div border=\"1px solid\" color=\" #ccc\" padding=\"50px\"> <th><font color=\"white\">Test</th> <th><font color=\"white\">Passed</th><th><font color=\"white\">Failed</th> <th><font color=\"white\">Execution time</th>");
while ( (line=br.readLine()) != null)
{
sb.append(line);
}
String textOnly = Jsoup.parse(sb.toString()).text();
int pass=0;
int fail=0;
for(int i=0;i<s.length;i++)
{
String[] s1=s[i].split(" ");
System.out.println("s1.........."+s1[1]);
if(textOnly.contains(s1[0]))
{
if(textOnly.contains(s[i])&&s1[1].equals("1"))
{
System.out.println(s[i]+"pass");
bw.write("<tr><td>" + s1[0] + "</td><td>" + "1" + "</td><td>" + "0" + "</td><td>"+ "200sec" + "</td></tr>");
++pass;
}
else{
System.out.println("fail"+s1[0]);
bw.write("<tr><td>" + s1[0] + "</td><td>" + "0" + "</td><td>" + "1" + "</td><td>"+ "200sec" + "</td></tr>");
++fail;
}
}
else{
bw.write("<tr><td>" + s1[0] + "</td><td>" + "-" + "</td><td>" + "-" + "</td><td>"+ "-" + "</td></tr>");
}
}
bw.write("<tr><th>" + "Total" + "</th><th>" + pass + "</th><th>" + fail + "</th></tr>");
bw.write("</tr></table></Body></html>");
bw.close();
return textOnly;
}
}
Thanks in advance.