Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    /**
     * Converts the ampersand, quote, prime, less-than and greater-than
     * characters to their corresponding HTML entities in the given string.
     */
    public static String htmlEntities(String text) {
        return text.replaceAll("&", "&").replaceAll("\"", """).replaceAll("'", "′")
                .replaceAll("<", "&lt;").replaceAll(">", "&gt;");
    }
}