Here you can find the source of bold(String str)
public static String bold(String str)
//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("&", "&"); text = text.replaceAll(">", ">"); text = text.replaceAll("<", "<"); text = text.replaceAll("\"", """); text = text.replaceAll("\\n", "<br/>"); text = text.replaceAll("[\\x0B\\f\\r]+", ""); return text; } }