/FileSearchSys/test/com/FSS/test/test.java
Java | 51 lines | 43 code | 7 blank | 1 comment | 9 complexity | fa4963a57353930b8d1aa20b4d94f53c MD5 | raw file
- package com.FSS.test;
-
- import java.io.FileInputStream;
- import java.io.FileNotFoundException;
- import java.io.IOException;
-
- import org.apache.poi.hwpf.HWPFDocument;
-
- import org.apache.poi.hwpf.usermodel.Paragraph;
- import org.apache.poi.hwpf.usermodel.Range;
-
- public class test {
- public static void main(String args[]) throws FileNotFoundException,
- IOException {
- HWPFDocument doc = new HWPFDocument(new FileInputStream(
- "e:\\Document\\b7???????2009?????????.doc"));
- Range r = doc.getRange(); // ??word?????
- int lenParagraph = r.numParagraphs();// ?????
- // Paragraph p;
- String firstP = null;
- StringBuffer secondP = new StringBuffer();//????????;
- int count = 0;
- for (int x = 0; x < lenParagraph; x++) {
- Paragraph p = r.getParagraph(x);
- String text = p.text();
-
- if (text.trim().length() == 0){
- if(count>=2)
- break;
- continue;
- }
-
- else {
- count++;
- if(count == 1)
- firstP = text;
- else{
- secondP.append(text.substring(0, text.length()-1));
- }
-
- }
- }
- System.out.println(secondP);
- for (int x = 0; x < lenParagraph; x++) {
- Paragraph p = r.getParagraph(x);
- String text = p.text();
- if(text.matches(".*???.*\\s"))
- System.out.println(text);
- }
- }
- }