Is there a method in Java that allows me to replace all HTML special characters into their encoded e
        Posted  
        
            by Siracuse
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Siracuse
        
        
        
        Published on 2010-04-26T03:55:31Z
        Indexed on 
            2010/04/26
            4:03 UTC
        
        
        Read the original article
        Hit count: 337
        
I have a textfile which my Java program is modifying and putting into an HTML file for display.
However, this textfile contains lots of HTML unsafe characters such as "<" and the ">" which would need to be encoded into  & gt; (sans space) and & lt;.
Is there some library method I can use to sanatize my text document to replace all these HTML special characters with their safe encoded equivelants?
© Stack Overflow or respective owner