Sample code for 30+ languages & platforms
Java Requires Chilkat v11.1.0+

HTML Encoding

Demonstrates HTML encoding and decoding.

Chilkat Java Downloads

Chilkat2 Java
import com.chilkatsoft.chilkat2.Crypt2;

public class ChilkatExample {

    public static void main(String[] args) {
        Crypt2 crypt = new Crypt2();

        String s = "< é ü ç Ω Hello & World ✓ >";

        String htmlEncoded = crypt.encodeString(s, "utf-8", "html");
        System.out.println(htmlEncoded);

        // Output:
        // < &eacute; &uuml; &ccedil; &ohm; Hello & World &check; >

        // To decode:
        s = crypt.decodeString(htmlEncoded, "utf-8", "html");
        System.out.println(s);

        // Output:
        // < é ü ç Ω Hello & World ✓ >
    }
}