Java HTML Encode textToHtml(String text)

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

Description

text To Html

License

Open Source License

Declaration

public static String textToHtml(String text) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2004, 2007 Boeing./*from   ww  w  . j  av  a2 s.  co  m*/
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Boeing - initial API and implementation
 *******************************************************************************/

public class Main {
    public static String textToHtml(String text) {
        if (text == null) {
            return "";
        }
        text = text.replaceAll("&", "&");
        text = text.replaceAll(">", ">");
        text = text.replaceAll("<", "&lt;");
        text = text.replaceAll("\"", "&quot;");
        text = text.replaceAll("\\n", "<br/>");
        text = text.replaceAll("[\\x0B\\f\\r]+", "");
        return text;
    }
}

Related

  1. textToHtml(String html)
  2. textToHTML(String message)
  3. textToHtml(String s)
  4. textToHtml(String text)
  5. textToHTML(String text)
  6. textToHTML(String text)
  7. textToHTML(String text)
  8. toHtml(String message)
  9. toHTML(String msg)