This API “moves in mysterious ways”

Ever tried to convert a HTML document to plain text with Java? We just had to convert HTML mails to plain text for displaying them in a text-field.

So, the first thing you’ll always do is search. Nearly no useful results – just one hint to JEditorPane. I tried that stuff out and it works, seriously! So, we’re using a Swing component to convert text. Klingt komisch, ist aber so! ( 😉 for all Maus fans ).

JEditorPane pane = new JEditorPane("text/html", html);
String plainText = pane.getDocument().getText(0,