package org.jsoupstream.example;

import java.io.FileInputStream;
import java.io.InputStream;
import java.net.URL;
import org.jsoupstream.HtmlParser;
import org.jsoupstream.HtmlLexer;

public class TestParser {

	public static void main(String[] args) {
		InputStream css_is = null;
		InputStream html_is = null;
		char c = (char)0;
		int count = 1;
		int line = 1;

		try
		{
            if ( args.length > 2 )
            {
                count = Integer.parseInt( args[2] );
            }

            // parse the CSS and create a parser 1 time only
            css_is = new FileInputStream(args[0]);
            HtmlParser parser = new HtmlParser(css_is);
            css_is.close();

            for (int i = 0; i < count; i++)
            {
                // URL url = new URL("http://www.oracle.com/");
                // URL url = new URL( args[1] );
                // html_is = url.openStream();

                html_is = new FileInputStream(args[1]);
                HtmlLexer lexer = new HtmlLexer(html_is);
                String result = parser.parse( lexer );
                html_is.close();
                System.out.print( result );

                // parser must be reset if it to be reused
                parser.reset( );
            }
		} catch(Exception e) {
			// if any I/O error occurs
			System.err.println("ERROR: "+e.getMessage());
			e.printStackTrace();
		}
	}
}

@@ -680,24 +680,264 @@
 s.close();%0A%0A
+            if ( args.length %3E 3 )%0A            %7B%0A                if ( args%5B3%5D.startsWith( %22min%22 ) %7C%7C args%5B3%5D.equalsIgnoreCase( %22yes%22 ) )%0A                %7B%0A                    parser.setMinimizeHtml( true );%0A                %7D%0A            %7D%0A%0A
             
@@ -1002,55 +1002,61 @@
     
-// URL url = new URL(%22http://www.oracle.com/%22);
+if ( args%5B1%5D.startsWith( %22http%22 ) )%0A                %7B
 %0A   
@@ -1068,18 +1068,19 @@
         
-//
+   
  URL url
@@ -1118,18 +1118,19 @@
         
-//
+   
  html_is
@@ -1146,25 +1146,85 @@
 enStream();%0A
-%0A
+                %7D%0A                else%0A                %7B%0A    
             
@@ -1261,18 +1261,39 @@
 eam(
+ 
 args%5B1%5D
+ 
 );%0A
+                %7D%0A%0A
     
@@ -1336,23 +1336,25 @@
 mlLexer(
+ 
 html_is
+ 
 );%0A     
@@ -1569,17 +1569,16 @@
 r.reset(
- 
 );%0A     

add min option and http files