Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    /** return version of the string that is ready for xml output (i.e. convert '<' to '&lt', etc)
     */
    public static String xmlSafe(String s) {
        String safeString = s;

        safeString = safeString.replaceAll("&", "&amp;");
        safeString = safeString.replaceAll("<", "&lt;");
        safeString = safeString.replaceAll(">", "&gt;");
        safeString = safeString.replaceAll("'", "&apos;");
        safeString = safeString.replaceAll("\"", "&quot;");
        return safeString;
    }
}