removing html tags using a for loop in Java
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/240546/removing-html-from-a-java-string">Removing HTML from a Java String</a>  </p>
</blockquote>



<p>I am having a problem removing htmls tags from a text file in java. I know it would be easy to use something like</p>

<pre><code>str=str.toString().replaceAll("\\&lt;.*?&gt;","");
</code></pre>

<p>However I want to know if I could split the string and go throught and replace everything srarting from &lt; to > with "". </p>

<p>I tried </p>

<pre><code>String [] str= "&lt;tag&gt;with some string &lt;/tag&gt;";
String  s="";
    for (i=0; i &lt; str.length; i++)
    {
        if (str[i].toString()=="&lt;")
        {
            str[i]="";
        }
        else if (str[i].toString()=="&gt;")
        {
            s=s+str[i+1];
        }
    }
</code></pre>

<p>when i try printing the new string s, it just prints out with just white space. 
thanks for the help</p>
