public class ToHtmlDemo
{
public static void main (String[] args) throws ParserException
{
// PrintWriter out= new PrintWriter();
try{
FileOutputStream htmlparserOutput = new FileOutputStream("test2.txt");
PrintWriter out=null;
out = new PrintWriter(htmlparserOutput);
Parser parser = new Parser ("test.htm");
//StringBuffer html = new StringBuffer (4096);
for (NodeIterator i = parser.elements();i.hasMoreNodes();){
// out.print (list.elementAt(i).toHtml ());
// html.append
out.print(i.nextNode().toHtml ());}
regards:
I use htmlparser http://htmlparser.sourceforge.net/javadoc/index.html
to parse existing File test.htm
and output to test2.txt.
"javac ToHtmlDemo" is ok.
but when
"java ToHtmlDemo"
exception say
encoding change from ISO-8859-1 to Big5
----------------------------------
Do I miss something important?
thank you
may god be with you
Followings is my code.
import org.htmlparser.Parser;
import org.htmlparser.util.NodeIterator;
import org.htmlparser.util.ParserException;
import java.io.*;
public class ToHtmlDemo
{
public static void main (String[] args) throws ParserException
{
// PrintWriter out= new PrintWriter();
try{
FileOutputStream htmlparserOutput = new FileOutputStream("test2.txt");
PrintWriter out=null;
out = new PrintWriter(htmlparserOutput);
Parser parser = new Parser ("test.htm");
//StringBuffer html = new StringBuffer (4096);
for (NodeIterator i = parser.elements();i.hasMoreNodes();){
// out.print (list.elementAt(i).toHtml ());
// html.append
out.print(i.nextNode().toHtml ());}
// System.out.println (html);
out.close();
htmlparserOutput.close();
}
catch(IOException e)
{
}
// test2.close();
}
}
try setting the encoding before starting the parse:
Parser parser = new Parser ("test.htm");
--> parser.setEncoding ("Big5");
//StringBuffer html = new StringBuffer (4096);
regards:
It test ok.
thank you all
May god be with you all