bloritsch 01/07/20 15:10:39
Modified: src/org/apache/cocoon Main.java
Log:
Add support for reading URIs to process from an input file.
Revision Changes Path
1.11 +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.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- Main.java 2001/07/18 10:44:26 1.10
+++ Main.java 2001/07/20 22:10:39 1.11
@@ -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.10 $ $Date: 2001/07/18 10:44:26 $
+ * @version CVS $Revision: 1.11 $ $Date: 2001/07/20 22:10:39 $
*/
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]