Java HTML Encode toHtml(String p_str)

Here you can find the source of toHtml(String p_str)

Description

to Html

License

Open Source License

Declaration

public static final String toHtml(String p_str) 

Method Source Code

//package com.java2s;
/**//www.j a v  a 2 s .c  o  m
 * Copyright 2003 ZhongTian, Inc. All rights reserved.
 *
 * qingdao tec PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 *
 * $Id: DBUtil.java,v 1.1 2006/05/17 09:19:30 wiserd Exp $
 * File:DBUtil.java
 * Date Author Changes
 * March 10 2003 wangdeliang Created
 */

public class Main {

    public static final String toHtml(String p_str) {
        if (p_str == null || p_str.length() == 0)
            return "";
        p_str = p_str.replaceAll("<", "&lt;");
        p_str = p_str.replaceAll(">", "&gt;");
        p_str = p_str.replaceAll("&", "&amp;");
        p_str = p_str.replaceAll("\"", "&quot;");
        return p_str;
    }
}

Related

  1. textToHTML(String text)
  2. textToHTML(String text)
  3. toHtml(String message)
  4. toHTML(String msg)
  5. toHTML(String org, boolean inputValue)
  6. toHTML(String plainText)
  7. toHTML(String rawText)
  8. toHTML(String s)
  9. toHtml(String s)