//Code Example
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.lang.reflect.Method;
import org.ccil.cowan.tagsoup.CommandLine;
public class test {
public static void main(String[] args) throws Exception {
String inFile = "raw.html";
String outFile = "good.html";
CommandLine cl = new CommandLine();
Method m = cl.getClass().getDeclaredMethod("process", new Class[]{String.class, OutputStream.class});
m.setAccessible(true);
OutputStream os = new FileOutputStream(outFile);
m.invoke(cl, new Object[]{inFile, os});
os.close();
}
}
也可以直接使用命令如下;
java -jar tagsoup-1.2.1.jar --files 1.html
则输出为1.xhtml