Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//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;
    }
}