JAVA读word的简单实现

读取word文件有两种方法,用jacob包,可以修改生成word文件内容。如果只读取word里的文本内容的话,可以用poi读取word文件,先到 http://www.ibiblio.org/maven2/org/textmining/tm-extractors/下载tm-extractors-0.4.jar包
 
package sa.fs121.rpt;

import java.io.FileInputStream;

import org.textmining.text.extraction.WordExtractor;

public class Test {

   /**
    * @param args
    */
   public static void main(String[] args) {

     try {
      FileInputStream in = new FileInputStream( "C:/1.doc");

      WordExtractor extractor = new WordExtractor();
        
      String str = extractor.extractText(in);
        
      System.out.println(str);
    } catch (Exception e) {
      e.printStackTrace();
    }

  }

}

你可能感兴趣的:(职场,word,Office,休闲)