import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import org.apache.poi.hwpf.HWPFDocument;
import org.apache.poi.hwpf.usermodel.Range;
public class test {
/**
* @param args
*/
public static void main(String[] args)
{
File file = new File("D://a.doc");
extractMsWordText(file);
}
/**
* 读取Word2003文档
* @param file
* @return
*/
public static String extractMsWordText(File file)
{
try
{
InputStream input = new FileInputStream(file);
HWPFDocument msWord = new HWPFDocument(input);
Range range = msWord.getRange();
String msWordText = range.text();
System.out.println( msWordText);
}
catch (FileNotFoundException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
return null;
}
}
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import org.apache.poi.hwpf.HWPFDocument;
import org.apache.poi.hwpf.usermodel.Range;
public class test {
/**
* @param args
*/
public static void main(String[] args)
{
File file = new File("D://a.doc");
extractMsWordText(file);
}
/**
* 读取Word2003文档
* @param file
* @return
*/
public static String extractMsWordText(File file)
{
try
{
InputStream input = new FileInputStream(file);
HWPFDocument msWord = new HWPFDocument(input);
Range range = msWord.getRange();
String msWordText = range.text();
System.out.println( msWordText);
}
catch (FileNotFoundException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
return null;
}
}