Add in a main() method, so people can stop moaning

git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@421238 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Nick Burch 2006-07-12 11:22:50 +00:00
parent d64e872005
commit c8b4f5798c

View 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