0
|
1 package de.mpiwg.itgroup.eSciDoc.Tools;
|
|
2
|
|
3 import java.io.IOException;
|
|
4 import java.io.Reader;
|
|
5
|
|
6 import javax.swing.text.html.HTMLEditorKit;
|
|
7 import javax.swing.text.html.parser.ParserDelegator;
|
|
8
|
|
9 //import javax.swing.text.html.*;
|
|
10 //import javax.swing.text.html.parser.*;
|
|
11
|
|
12
|
|
13 public class Html2Text extends HTMLEditorKit.ParserCallback {
|
|
14 StringBuffer s;
|
|
15
|
|
16 public Html2Text() {}
|
|
17
|
|
18 public void parse(Reader in) throws IOException {
|
|
19 s = new StringBuffer();
|
|
20 ParserDelegator delegator = new ParserDelegator();
|
|
21 // the third parameter is TRUE to ignore charset directive
|
|
22 delegator.parse(in, this, Boolean.TRUE);
|
|
23 }
|
|
24
|
|
25 public void handleText(char[] text, int pos) {
|
|
26 s.append(text);
|
|
27 }
|
|
28
|
|
29 public String getText() {
|
|
30 return s.toString();
|
|
31 }
|
|
32
|
|
33 }
|
|
34
|