Java HTML Create bold(String str)

Here you can find the source of bold(String str)

Description

bold

License

Open Source License

Declaration

public static String bold(String str) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2004, 2007 Boeing./*from www  .  j  a va  2  s. c o  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 bold(String str) {
        return "<b>" + textToHtml(str) + "</b>";
    }

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

Related

  1. bold()
  2. bold(String s)
  3. bold(String text)
  4. bold(String text)
  5. boldenRefOrType(String label)
  6. boldHTML(String input)