java - Separating contents while writing a file -


here brief explanation of want achieve overall:

get contents website, remove unwanted html tags, filtering it. segregating contents. if workstations put in 1 file , if servers file.

i provide brief overview of code website.

   <tr class="rowlight">       <td width=0>          <a href="report.asp?reportid=100&amp;sp=service+pack+4&amp;os=microsoft+windows+2000+server">             <img border=0 src="images/icolink3.gif" alt="open target" width=11 height=11>          </a>       </td>       <td class=simpletextsmall>&nbsp;microsoft&nbspwindows&nbsp2000&nbspserver&nbsp;</td>       <td class=simpletextsmall>&nbsp;service&nbsppack&nbsp4&nbsp;</td>       <td class=simpletextsmall>&nbsp;30&nbsp;</td>    </tr>    <tr class="rowdark">       <td width=0>          <a href="report.asp?reportid=100&amp;sp=&amp;os=microsoft+windows+7+enterprise">             <img border=0 src="images/icolink3.gif" alt="open target" width=11 height=11>          </a>       </td>       <td class=simpletextsmall>&nbsp;microsoft&nbspwindows&nbsp7&nbspenterprise&nbsp;</td>       <td class=simpletextsmall>&nbsp;</td>       <td class=simpletextsmall>&nbsp;794&nbsp;</td>    </tr> 

till , code capable of getting above code in .csv file as

microsoft windows 2000 server   service pack 4  30 microsoft windows 7 enterprise        ;        794 

a ";" being used in place of space.

i want servers , windows 7 separate. unable logic.

here code filtering out content (it not include opening url connection, bufferwriter, reader etc)

  try {      int = 0;      int j = 0;      while ((inputline = in.readline()) != null) {         if (inputline.contains(s)) {            j++;             if (j >= 7) {               i++;                string s0 = inputline;                string m = "<td class=simpletextsmall>&nbsp;</td>";               if (s0.contains(m)) {                  s0 = " ";               } else {                  int startposition = s0.indexof(';');                  int endposition = s0.indexof(';', startposition + 1);                  s0 = s0.substring(startposition + 1, endposition);                   s0 = s0.replaceall("&nbsp", " ");                  s0 = s0.replaceall(",", "");               }                out.write(s0);               if (i != 3) {                  out.write(',');               }                if (i == 3) {                  = 0;                  out.newline();                }            }         }      }   } 

here "j" , "i" mean:

since want new line created after every entry, have counter (i). helps in putting "," .csv files.

the first 7 lines of webpage contain "s" , don't need them removed them.

i hope easy understand. have been stuck on past 2 weeks.

any appreciated.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -