]> source.dussan.org Git - poi.git/commitdiff
Add in a main() method, so people can stop moaning
authorNick Burch <nick@apache.org>
Wed, 12 Jul 2006 11:22:50 +0000 (11:22 +0000)
committerNick Burch <nick@apache.org>
Wed, 12 Jul 2006 11:22:50 +0000 (11:22 +0000)
git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@421238 13f79535-47bb-0310-9956-ffa450edef68

src/scratchpad/src/org/apache/poi/hwpf/extractor/WordExtractor.java

index d34fa78c26dd3738cdbf16fde0334c2c7d241191..d1422288f4f111de2a591866b8b2adcb41ee9854 100644 (file)
@@ -2,6 +2,7 @@ package org.apache.poi.hwpf.extractor;
 
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.FileInputStream;
 import java.io.UnsupportedEncodingException;
 import java.util.Iterator;
 
@@ -47,6 +48,23 @@ public class WordExtractor {
        public WordExtractor(HWPFDocument doc) throws IOException {
                this.doc = doc;
        }
+
+       /**
+        * Command line extractor, so people will stop moaning that
+        *  they can't just run this.
+        */
+       public static void main(String[] args) throws IOException {
+               if(args.length == 0) {
+                       System.err.println("Use:");
+                       System.err.println("   java org.apache.poi.hwpf.extractor.WordExtractor <filename>");
+                       System.exit(1);
+               }
+
+               // Process the first argument as a file
+               FileInputStream fin = new FileInputStream(args[0]);
+               WordExtractor extractor = new WordExtractor(fin);
+               System.out.println(extractor.getText());
+       }
        
        /**
         * Get the text from the word file, as an array with one String