Here you can find the source of stripHTML(String html)
public static String stripHTML(String html)
//package com.java2s; /*//w w w . j av a 2s .c om * Copyright (c) 2014, 2015 Eike Stepper (Berlin, Germany) and others. * 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: * Eike Stepper - initial API and implementation */ import javax.swing.text.MutableAttributeSet; import javax.swing.text.html.HTML.Tag; import javax.swing.text.html.HTMLEditorKit; import javax.swing.text.html.parser.ParserDelegator; import java.io.IOException; import java.io.StringReader; public class Main { public static String stripHTML(String html) { try { final StringBuilder builder = new StringBuilder(); new ParserDelegator().parse(new StringReader(html), new HTMLEditorKit.ParserCallback() { @Override public void handleText(char[] text, int pos) { builder.append(text); } @Override public void handleSimpleTag(Tag t, MutableAttributeSet a, int pos) { if (t.breaksFlow()) { builder.append("\n"); } } }, Boolean.TRUE); return builder.toString(); } catch (IOException ex) { return html; } } }