Guest User

Untitled

a guest
Nov 22nd, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. public void actionPerformed(ActionEvent e) {
  2. if(e.getSource()==openfile){
  3. JFileChooser fc=new JFileChooser();
  4. int i=fc.showOpenDialog(this);
  5. if(i==JFileChooser.APPROVE_OPTION){
  6. File f=fc.getSelectedFile();
  7. String filepath=f.getPath();
  8. JT_Filechooser.setText(filepath);
  9. JT_FileName.setText(f.getName());
  10. try{
  11. FileInputStream fis = new FileInputStream(f.getAbsolutePath());
  12.  
  13. XWPFDocument document = new XWPFDocument(fis);
  14.  
  15. List<XWPFParagraph> paragraphs = document.getParagraphs();
  16.  
  17. int count = 0;
  18. for (XWPFParagraph para : paragraphs) {
  19. count++;
  20. System.out.println(para.getText());
  21. }
  22. System.out.println("No. of lines : "+count);
  23. JT_LinesCount.setText(Integer.toString(count));
  24. fis.close();
  25. }catch (Exception ex) {ex.printStackTrace(); }
  26.  
  27. }
  28. }
  29. }
  30.  
  31. int charCount = 0;
  32.  
  33. charCount += para.getText().length();
Add Comment
Please, Sign In to add comment