Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2015 CA.  All rights reserved.
 *
 * This source file is licensed under the terms of the Eclipse Public License 1.0
 * For the full text of the EPL please see https://www.eclipse.org/legal/epl-v10.html
 *******************************************************************************/

public class Main {
    public static String convertToXMLString(String instr) {
        //XML has a special set of characters that cannot be used in normal XML strings
        String ourstr = instr;
        ourstr = ourstr.replace("&", "&");
        ourstr = ourstr.replace("<", "&lt;");
        ourstr = ourstr.replace(">", "&gt;");
        ourstr = ourstr.replace("\"", "&quot;");
        ourstr = ourstr.replace("'", "&#39;");

        return ourstr;
    }
}