Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

public class Main {
    /**
     * Escapes special HTML entities
     * @param text
     * @return text with HTML entities escaped
     */
    public static String escapeXMLEntities(String text) {
        if (text == null)
            return null;
        text = text.replace("&", "&");
        text = text.replace("\"", """);
        text = text.replace("<", "&lt;");
        text = text.replace(">", "&gt;");
        text = text.replace("'", "&#039;");
        return text;
    }
}