Java HTML Entities htmlEntities(String text)

Here you can find the source of htmlEntities(String text)

Description

Converts the ampersand, quote, prime, less-than and greater-than characters to their corresponding HTML entities in the given string.

License

Open Source License

Declaration

public static String htmlEntities(String text) 

Method Source Code

//package com.java2s;

public class Main {
    /**// www.j  a v  a 2  s.  c om
     * 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("'", "&prime;").replaceAll("<", "&lt;")
                .replaceAll(">", "&gt;");
    }
}

Related

  1. htmlEntites(String str)
  2. htmlEntites(String str)
  3. htmlEntities(String s)
  4. htmlEntityToString(String dataStr)