KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > Indent


1 import au.id.jericho.lib.html.*;
2 import java.util.*;
3 import java.io.*;
4 import java.net.*;
5
6 public class Indent {
7     public static void main(String JavaDoc[] args) throws Exception JavaDoc {
8         String JavaDoc sourceUrlString="data/test.html";
9         if (args.length==0)
10           System.err.println("Using default argument of \""+sourceUrlString+'"');
11         else
12             sourceUrlString=args[0];
13         if (sourceUrlString.indexOf(':')==-1) sourceUrlString="file:"+sourceUrlString;
14         PHPTagTypes.register();
15         MasonTagTypes.register();
16         Source source=new Source(new URL(sourceUrlString));
17         source.setLogWriter(new OutputStreamWriter(System.err)); // send log messages to stderr
18
source.fullSequentialParse();
19
20         String JavaDoc indentText=" ";
21         boolean tidyTags=true;
22         boolean collapseWhiteSpace=false;
23         boolean indentAllElements=false;
24         source.indent(indentText,tidyTags,collapseWhiteSpace,indentAllElements).writeTo(new OutputStreamWriter(System.out));
25     }
26 }
27
Popular Tags