Print out size of extracted text in CommandLineExtractor

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1763483 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Dominik Stadler 2016-10-05 19:59:50 +00:00
parent 86eafd3c44
commit 2bfa5a50de

View File

@ -33,27 +33,30 @@ public class CommandLineTextExtractor {
System.err.println(" CommandLineTextExtractor <filename> [filename] [filename]");
System.exit(1);
}
for(int i=0; i<args.length; i++) {
System.out.println(DIVIDER);
File f = new File(args[i]);
System.out.println(f);
POITextExtractor extractor =
ExtractorFactory.createExtractor(f);
try {
POITextExtractor metadataExtractor =
extractor.getMetadataTextExtractor();
System.out.println(" " + DIVIDER);
System.out.println(metadataExtractor.getText());
System.out.println(" " + DIVIDER);
System.out.println(extractor.getText());
System.out.println(DIVIDER);
} finally {
extractor.close();
}
}
for (String arg : args) {
System.out.println(DIVIDER);
File f = new File(arg);
System.out.println(f);
POITextExtractor extractor =
ExtractorFactory.createExtractor(f);
try {
POITextExtractor metadataExtractor =
extractor.getMetadataTextExtractor();
System.out.println(" " + DIVIDER);
String metaData = metadataExtractor.getText();
System.out.println(metaData);
System.out.println(" " + DIVIDER);
String text = extractor.getText();
System.out.println(text);
System.out.println(DIVIDER);
System.out.println("Had " + metaData.length() + " characters of metadata and " + text.length() + " characters of text");
} finally {
extractor.close();
}
}
}
}