[Htmlparser-user] problem with format of text file after converting html to text file ...
Brought to you by:
derrickoswald
From: ChennaDulla <che...@go...> - 2003-02-06 22:17:22
|
Hi, I downloded htmlparser1.2 zip and i put htmlparser.jar and under lib on my server and working fine to convert html to text file .. but the prob is the convertion of text file format doesn't look good ... i am sending the text file as attachment generated from html file .. Here is the code i am using to convert html to text file ... import org.htmlparser.util.HTMLEnumeration; import org.htmlparser.util.HTMLParserException; import org.htmlparser.HTMLNode; import org.htmlparser.HTMLParser; import java.io.*; import java.util.Properties; public class StringExtractor { public StringExtractor() { } public void extractStrings(String htmlFile) throws HTMLParserException { try{ HTMLParser parser = new HTMLParser(htmlFile); BufferedWriter thewriter = new BufferedWriter(new FileWriter("/export/home/mailfiles/d.txt")); HTMLNode node; StringBuffer results= new StringBuffer(); for (HTMLEnumeration e = parser.elements();e.hasMoreNodes();) { node = e.nextHTMLNode(); thewriter.write(node.toPlainTextString()); } thewriter.close(); }catch(IOException e) { System.out.println("error in ConvertJspToHtml.java==="+e ); } } } Thanks, Chenna Dulla, GoneHome Inc. 1278 SouthMain St. Canton, Ohio - 44720 tel: 330-649-9258 (W) 440-605-1628 (R) |