(Java) Convert HTML to plain-text
Demonstrates how to convert HTML to plain-text.
import com.chilkatsoft.*;
public class ChilkatExample {
static {
try {
System.loadLibrary("chilkat");
} catch (UnsatisfiedLinkError e) {
System.err.println("Native code library failed to load.\n" + e);
System.exit(1);
}
}
public static void main(String argv[])
{
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
CkHtmlToText h2t = new CkHtmlToText();
// Set the HTML:
String html;
html = "<html><body><p>This is a test.</p><blockquote>Here is text within a blockquote</blockquote></body></html>";
String plainText;
plainText = h2t.toText(html);
System.out.println(plainText);
// The output looks like this:
// This is a test.
//
// Here is text within a blockquote
}
}
|