Created
June 5, 2013 08:44
-
-
Save aisensiy/5712530 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//package com.informit.poi; | |
// Import POI classes | |
import org.apache.poi.POIXMLDocument; | |
import org.apache.poi.xwpf.usermodel.XWPFDocument; | |
import org.apache.poi.POIXMLTextExtractor; | |
import org.apache.poi.hwpf.extractor.WordExtractor; | |
import org.apache.poi.xwpf.extractor.XWPFWordExtractor; | |
import org.apache.poi.openxml4j.opc.OPCPackage; | |
import org.apache.poi.extractor.ExtractorFactory; | |
import org.apache.poi.POITextExtractor; | |
// Import Java classes | |
import java.io.*; | |
import java.util.*; | |
public class WordSampleReader | |
{ | |
public static void main( String[] args ) | |
{ | |
if( args.length == 0 ) | |
{ | |
System.out.println( "Usage: WordSampleReader " ); | |
System.exit( 0 ); | |
} | |
String filename = args[ 0 ]; | |
System.out.println(filename); | |
try | |
{ | |
POITextExtractor poitex = ExtractorFactory.createExtractor(new File(filename)); | |
String text2007 = new String(poitex.getText().getBytes("GBK")); | |
System.out.println(text2007); | |
} | |
catch( Exception e ) | |
{ | |
e.printStackTrace(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment