bloritsch    01/07/22 14:19:32

  Modified:    src/org/apache/cocoon Tag: cocoon_20_branch Main.java
  Log:
  Add addition to read URIs from files
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.4.2.7   +33 -1     xml-cocoon2/src/org/apache/cocoon/Main.java
  
  Index: Main.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/Main.java,v
  retrieving revision 1.4.2.6
  retrieving revision 1.4.2.7
  diff -u -r1.4.2.6 -r1.4.2.7
  --- Main.java 2001/07/18 10:44:39     1.4.2.6
  +++ Main.java 2001/07/22 21:19:31     1.4.2.7
  @@ -15,6 +15,8 @@
   import java.io.IOException;
   import java.io.OutputStream;
   import java.io.PrintStream;
  +import java.io.BufferedReader;
  +import java.io.FileReader;
   import java.net.MalformedURLException;
   import java.util.HashSet;
   import java.util.ArrayList;
  @@ -48,7 +50,7 @@
    * Command line entry point.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Stefano Mazzocchi</a>
  - * @version CVS $Revision: 1.4.2.6 $ $Date: 2001/07/18 10:44:39 $
  + * @version CVS $Revision: 1.4.2.7 $ $Date: 2001/07/22 21:19:31 $
    */
   
   public class Main {
  @@ -65,11 +67,16 @@
       protected static final int XSP_OPT =         'x';
       protected static final int AGENT_OPT =       'a';
       protected static final int ACCEPT_OPT =      'p';
  +    protected static final int URI_FILE =        'f';
   
       protected static final String DEFAULT_USER_AGENT = Constants.COMPLETE_NAME;
       protected static final String DEFAULT_ACCEPT = "text/html, */*";
   
       protected static final CLOptionDescriptor [] options = new CLOptionDescriptor 
[] {
  +        new CLOptionDescriptor("uriFile",
  +                               CLOptionDescriptor.ARGUMENT_REQUIRED,
  +                               URI_FILE,
  +                               "use a text file with uris to process (1 uri per 
line)"),
           new CLOptionDescriptor("help",
                                  CLOptionDescriptor.ARGUMENT_DISALLOWED,
                                  HELP_OPT,
  @@ -112,6 +119,27 @@
                                  "use given string for accept header"),
       };
   
  +    public static void processFile(String filename, List uris) {
  +        try {
  +            BufferedReader uriFile = new BufferedReader(new FileReader(filename));
  +            boolean eof = false;
  +
  +            while (! eof) {
  +                String uri = uriFile.readLine();
  +
  +                if (null == uri) {
  +                    eof = true;
  +                } else {
  +                    uris.add(NetUtils.normalize(uri.trim()));
  +                }
  +            }
  +
  +            uriFile.close();
  +        } catch (Exception e) {
  +            // ignore errors.
  +        }
  +    }
  +
   
       public static void main(String[] args) throws Exception {
   
  @@ -176,6 +204,10 @@
   
                   case Main.ACCEPT_OPT:
                       accept = option.getArgument();
  +                    break;
  +
  +                case Main.URI_FILE:
  +                    Main.processFile(option.getArgument(), targets);
                       break;
               }
           }
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     [EMAIL PROTECTED]
To unsubscribe, e-mail:          [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to