got packages working  
Author Message
thufir





PostPosted: 2005-1-24 6:35:00 Top

java-programmer, got packages working /////////command line///////////////
Microsoft Windows 2000 [Version 5.00.2195]
(C) Copyright 1985-2000 Microsoft Corp.

C:\>javac @comp

C:\>java -classpath
.;C:\java\classes\org\w3c\tidy\Tidy.jar;C:\java\classes\
atreides.jtidy.Tid
yTest

C:\>type comp
-d C:\java\classes\
-g
-sourcepath C:\java\sources\
-classpath .;C:\java\classes\;C:\java\classes\org\w3c\tidy\Tidy.jar

C:\java\sources\atreides\jtidy\TidyTest.java

C:\>type C:\java\sources\atreides\jtidy\TidyTest.java
// adapted from source available at:
//
<http://sourceforge.net/docman/display_doc.php?docid=1298&group_id=13153>


package atreides.jtidy;

import java.io.IOException;
import java.net.URL;
import java.io.BufferedInputStream;
import java.io.FileOutputStream;
import java.io.PrintWriter;
import java.io.FileWriter;
import org.w3c.tidy.Tidy;



public class TidyTest implements Runnable {

private String url;
private String outFileName;
private String errOutFileName;
private boolean xmlOut;

public TidyTest(String url, String outFileName, String
errOutFileName,
boolean xmlOut) {
this.url = url;
this.outFileName = outFileName;
this.errOutFileName = errOutFileName;
this.xmlOut = xmlOut;
}//tidyTest

public void run() {
URL u;
BufferedInputStream in;
FileOutputStream out;
Tidy tidy = new Tidy();

tidy.setXmlOut(xmlOut);
try {
tidy.setErrout(new PrintWriter(new
FileWriter(errOutFileName),
true));
u = new URL(url);
in = new BufferedInputStream(u.openStream());
out = new FileOutputStream(outFileName);
tidy.parse(in, out);
}//try
catch ( IOException e ) {
System.out.println( this.toString() + e.toString() );
}//catch
}//run

public static void main( String[] args ) {

String url = "http://www.google.com/";
String output = "output.txt"; //specify path?
String errorLog = "errorLog.txt"; //specify path?

TidyTest t1 = new TidyTest(url,output,errorLog,true);
Thread th1 = new Thread(t1);
th1.start();
}//main
}//TidyTest

C:\>