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,

One thought on “This API “moves in mysterious ways”

  1. Pingback: Howto convert HTML into plaintext « Stefon’s Blog

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s