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);
	}

 

相关文章:

  • 2021-07-14
  • 2021-12-15
  • 2022-12-23
  • 2021-11-04
  • 2022-12-23
  • 2022-12-23
  • 2022-01-08
猜你喜欢
  • 2022-12-23
  • 2021-08-23
  • 2022-12-23
  • 2021-11-06
  • 2022-02-19
  • 2022-12-23
相关资源
相似解决方案