zoukankan      html  css  js  c++  java
  • java 操作word 使用POI3.7

    public static void readWord2003(String filename) {
    		InputStream inputStream = null;
    		WordExtractor wordExtractor = null;
    		String word = null;
    		try {
    			inputStream = new FileInputStream(filename);
    			wordExtractor = new WordExtractor(inputStream);
    			word = wordExtractor.getText();
    		} catch (FileNotFoundException e) {
    			e.printStackTrace();
    		} catch (IOException e) {
    			e.printStackTrace();
    		} finally {
    			if (null != inputStream) {
    				try {
    					inputStream.close();
    				} catch (IOException e) {
    					e.printStackTrace();
    				}
    			}
    		}
    		System.out.println(word);
    	}
    
    	public static void readWord2007(String filename) {
    		OPCPackage opcPackage = null;
    		XWPFWordExtractor xwpfWordExtractor = null;
    		String word = null;
    		try {
    			opcPackage = POIXMLDocument.openPackage(filename);
    			xwpfWordExtractor = new XWPFWordExtractor(opcPackage);
    			word = xwpfWordExtractor.getText();
    		} catch (IOException e) {
    			e.printStackTrace();
    		} catch (XmlException e) {
    			e.printStackTrace();
    		} catch (OpenXML4JException e) {
    			e.printStackTrace();
    		}
    		System.out.println(word);
    	}
    
  • 相关阅读:
    记录日常Linux常用软件
    CentOS7.2重置root密码的处理方法
    Nginx配置文件详细说明
    ES项目实战
    foreachRDD
    Hive的数据倾斜
    SparkStreaming实战(数据库(NoSQL))
    Spark(4)
    SparkStreming中 `transform()`算子的 的使用
    RDD源码分析
  • 原文地址:https://www.cnblogs.com/xiaoxian1369/p/2621935.html
Copyright © 2011-2022 走看看