Sample code for 30+ languages & platforms
Java

HTML Encoding

Demonstrates HTML encoding and decoding.

Chilkat Java Downloads

Java
import com.chilkatsoft.*;

public class ChilkatExample {

  static {
    try {
        System.loadLibrary("chilkat");
    } catch (UnsatisfiedLinkError e) {
      System.err.println("Native code library failed to load.\n" + e);
      System.exit(1);
    }
  }

  public static void main(String argv[])
  {
    CkCrypt2 crypt = new CkCrypt2();

    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 ✓ >
  }
}