需要相关七个jar
poi-3.7-20101029.jar
poi-ooxml-3.7-20101029.jar
poi-ooxml-schemas-3.7-20101029.jar
poi-scratchpad-3.7-20101029.jar
dom4j-1.6.1.jar
geronimo-stax-api_1.0_spec-1.0.jar
xmlbeans-2.3.0.jar
public static String wordExtractor(String fileName){
try{
InputStream in = new FileInputStream(fileName);
String header,footer,allText;
int end;
if(getSuffix(fileName).equals("doc")){
WordExtractor wordExtractor = new WordExtractor(in);
header = wordExtractor.getHeaderText();
footer = wordExtractor.getFooterText();
allText = wordExtractor.getText();
end = allText.indexOf(footer);
return allText.substring(header.length(), end);
}else if(getSuffix(fileName).equals("docx")){
OPCPackage opcPackage = POIXMLDocument.openPackage(fileName);
POIXMLTe