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 {
    private static final String[][] escapees = { { "&", "&amp;" }, { "<", "&lt;" }, { ">", "&gt;" },
            { "\"", "&quot;" } };

    public static String xmlEscape(String str) {
        for (String[] escapee : escapees) {
            str = str.replaceAll(escapee[0], escapee[1]);
        }
        return str;
    }
}