您的位置:首页 > Web前端 > HTML

如何使用tagsoup规格化html文件中标记代码

2011-10-27 22:33 316 查看
//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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: