PageRenderTime 38ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/FileSearchSys/test/com/FSS/test/test.java

http://wadamolyfproject.googlecode.com/
Java | 51 lines | 43 code | 7 blank | 1 comment | 9 complexity | fa4963a57353930b8d1aa20b4d94f53c MD5 | raw file
  1. package com.FSS.test;
  2. import java.io.FileInputStream;
  3. import java.io.FileNotFoundException;
  4. import java.io.IOException;
  5. import org.apache.poi.hwpf.HWPFDocument;
  6. import org.apache.poi.hwpf.usermodel.Paragraph;
  7. import org.apache.poi.hwpf.usermodel.Range;
  8. public class test {
  9. public static void main(String args[]) throws FileNotFoundException,
  10. IOException {
  11. HWPFDocument doc = new HWPFDocument(new FileInputStream(
  12. "e:\\Document\\b7???????2009?????????.doc"));
  13. Range r = doc.getRange(); // ??word?????
  14. int lenParagraph = r.numParagraphs();// ?????
  15. // Paragraph p;
  16. String firstP = null;
  17. StringBuffer secondP = new StringBuffer();//????????;
  18. int count = 0;
  19. for (int x = 0; x < lenParagraph; x++) {
  20. Paragraph p = r.getParagraph(x);
  21. String text = p.text();
  22. if (text.trim().length() == 0){
  23. if(count>=2)
  24. break;
  25. continue;
  26. }
  27. else {
  28. count++;
  29. if(count == 1)
  30. firstP = text;
  31. else{
  32. secondP.append(text.substring(0, text.length()-1));
  33. }
  34. }
  35. }
  36. System.out.println(secondP);
  37. for (int x = 0; x < lenParagraph; x++) {
  38. Paragraph p = r.getParagraph(x);
  39. String text = p.text();
  40. if(text.matches(".*???.*\\s"))
  41. System.out.println(text);
  42. }
  43. }
  44. }