Java tutorial
//package com.java2s; public class Main { /** * Encloses a string into a CDATA construct as defined in its * <a href="http://www.w3schools.com/xml/xml_cdata.asp">documentation</a> * @param string Original string * @return String enclosed by CDATA structure */ public static String cdata(String string) { String ret = null; if (string != null) { StringBuilder sb = new StringBuilder("<![CDATA["); sb.append(string); sb.append("]]>"); ret = sb.toString(); } return ret; } }