Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    public static String getAsAttribute(String attrName, String value) {
        if (value != null) {
            String val = value.replace("&", "&");
            //val = val.replace("\"", """);
            val = val.replace("\"", "'");
            val = val.replace("<", "&lt;").replace(">", "&gt;");
            return " " + attrName + "=\"" + val + "\" ";
        } else {
            return " " + attrName + "=\"\" ";
        }
    }
}