Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    public static final String START_CDATA = "<![CDATA[";
    public static final String END_CDATA_RE = "\\]\\]>";
    public static final String END_CDATA_REPLACE = "]]&gt;";

    /**
     * CDATA sections can not have a "]]>" in them. This method takes the input and wraps it up in one or more CDATA sections, converting any "]]>" strings into
     * "]]&gt;".
     */
    public static String wrapStringInCDATA(final String input) {
        final StringBuffer retValue = new StringBuffer("<![CDATA[");
        retValue.append(input.replaceAll(END_CDATA_RE, END_CDATA_RE + END_CDATA_REPLACE + START_CDATA));
        retValue.append("]]>");
        return retValue.toString();
    }
}