title: update HTML file using a javaProgram
body: <p>I am trying to get a item status every hourly basis and email(Html format) along with the past 4 hours data. I do not have db to store those past values, so I have planned to store them in the HTML file itself.  </p>
  
  <p>I have code to get html file contents as string but I need help to remove the bottom most row in the HTML table and append the new value to the first row because I have to send only past 5hours report. So while sending 7 pm report <code>&lt;tr&gt;&lt;td&gt;19-Mar 7.00 PM&lt;/td&gt; &lt;td&gt;4&lt;/td&gt; &lt;td&gt;31&lt;/td&gt; &lt;td&gt;50181&lt;/td&gt; &lt;td&gt;555&lt;/td&gt;&lt;/tr&gt;</code> should be added at <code>&lt;!--$NewRow to be inserted here$--&gt;</code> place in the code and text between <code>&lt;!--$ToBeRemoved_Start$--&gt;</code>and <code>&lt;!--$ToBeRemoved_End$--&gt;</code>should be removed.</p>
  
  <p>I also know that it can be achieved by getting the index value of commented markers and play with the replace, append, concatenate.. in html but I need to know whether there is an easy way to achieve it using some libs like jsoup etc.. Please let me know your thoughts.</p>
  
  <pre><code>public String getHTML_String() {
      StringBuilder contentBuilder = new StringBuilder();
      try {
          BufferedReader in = new BufferedReader(new FileReader("emailOutput.html"));
          String str;
          while ((str = in.readLine()) != null) {
              contentBuilder.append(str);
          }
          in.close();
      } catch (IOException e) {
      }
      return contentBuilder.toString();
  
  }
  </code></pre>
  
  <p>HtmlCodeBelow:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  
  &lt;head&gt;
    &lt;meta charset="ISO-8859-1"&gt;
    &lt;title&gt;Api Report&lt;/title&gt;
    &lt;style&gt;
      table {
        font-family: arial, sans-serif;
        border-collapse: collapse;
        width: 100%;
      }
      
      td,
      th {
        border: 1px solid #dddddd;
        text-align: left;
        padding: 8px;
      }
      
      tr:nth-child(even) {
        background-color: #dddddd;
      }
    &lt;/style&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
    &lt;h2&gt;Content Api&lt;/h2&gt;
    &lt;table&gt;
      &lt;tr&gt;
        &lt;th&gt;Date Time&lt;/th&gt;
        &lt;th&gt;Col1&lt;/th&gt;
        &lt;th&gt;Col2&lt;/th&gt;
        &lt;th&gt;Col3&lt;/th&gt;
        &lt;th&gt;Col4&lt;/th&gt;
      &lt;/tr&gt;
      &lt;!--$NewRow to be inserted here$--&gt;
      &lt;tr&gt;
        &lt;td&gt;19-Mar 6.00 PM&lt;/td&gt;
        &lt;td&gt;1.22%&lt;/td&gt;
        &lt;td&gt;24.75%&lt;/td&gt;
        &lt;td&gt;4.71 ms&lt;/td&gt;
        &lt;td&gt;7.67&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;19-Mar 5.00 PM&lt;/td&gt;
        &lt;td&gt;1.22%&lt;/td&gt;
        &lt;td&gt;24.75%&lt;/td&gt;
        &lt;td&gt;4.71 ms&lt;/td&gt;
        &lt;td&gt;8.67&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;19-Mar 4.00 PM&lt;/td&gt;
        &lt;td&gt;1.22%&lt;/td&gt;
        &lt;td&gt;24.75%&lt;/td&gt;
        &lt;td&gt;4.71 ms&lt;/td&gt;
        &lt;td&gt;7.67&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;19-Mar 3.00 PM&lt;/td&gt;
        &lt;td&gt;1.22%&lt;/td&gt;
        &lt;td&gt;24.75%&lt;/td&gt;
        &lt;td&gt;4.71 ms&lt;/td&gt;
        &lt;td&gt;7.67&lt;/td&gt;
      &lt;/tr&gt;
      &lt;!--$ToBeRemoved_Start$--&gt;
      &lt;tr&gt;
        &lt;td&gt;19-Mar 2.00 PM&lt;/td&gt;
        &lt;td&gt;1.22%&lt;/td&gt;
        &lt;td&gt;24.75%&lt;/td&gt;
        &lt;td&gt;4.71 ms&lt;/td&gt;
        &lt;td&gt;7.67&lt;/td&gt;
      &lt;/tr&gt;
      &lt;!--$ToBeRemoved_End$--&gt;
    &lt;/table&gt;
  &lt;/body&gt;
  
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>