1 17 18 19 20 package org.apache.lenya.util; 21 22 import java.io.BufferedInputStream ; 23 import java.io.File ; 24 import java.io.FileOutputStream ; 25 import java.io.FileWriter ; 26 import java.io.PrintWriter ; 27 import java.net.URL ; 28 29 import org.w3c.tidy.Tidy; 30 31 32 35 public class TidyCommandLine { 36 41 public static void main(String [] args) { 42 if (args.length != 3) { 43 System.err.println("Usage: java " + new TidyCommandLine().getClass().getName() + 44 " http://www.lenya.org index.xhtml error.log"); 45 46 return; 47 } 48 49 try { 50 new TidyCommandLine().tidy(new URL (args[0]), new File (args[1]), new File (args[2]), true); 51 } catch (Exception e) { 52 System.err.println(e); 53 } 54 } 55 56 66 public void tidy(URL url, File file, File err, boolean xhtml) 67 throws Exception { 68 Tidy tidy = new Tidy(); 69 tidy.setXmlOut(xhtml); 70 tidy.setErrout(new PrintWriter (new FileWriter (err.getAbsolutePath()), true)); 71 72 BufferedInputStream in = new BufferedInputStream (url.openStream()); 73 FileOutputStream out = new FileOutputStream (file.getAbsolutePath()); 74 tidy.parse(in, out); 75 } 76 } 77 | Popular Tags |