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 {
    /**
     * escape characters like <, &, >
     * @param text
     * @return
     */
    public static String encodeString(String text) {
        String ret = null;
        ret = text.replaceAll("&", "&amp;");
        ret = ret.replaceAll("<", "&lt;");
        ret = ret.replaceAll(">", "&gt;");
        ret = ret.replaceAll("'", "&apos;");
        ret = ret.replaceAll("\"", "&quot;");
        return ret;
    }
}