Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void actionPerformed(ActionEvent e) {
- if(e.getSource()==openfile){
- JFileChooser fc=new JFileChooser();
- int i=fc.showOpenDialog(this);
- if(i==JFileChooser.APPROVE_OPTION){
- File f=fc.getSelectedFile();
- String filepath=f.getPath();
- JT_Filechooser.setText(filepath);
- JT_FileName.setText(f.getName());
- try{
- FileInputStream fis = new FileInputStream(f.getAbsolutePath());
- XWPFDocument document = new XWPFDocument(fis);
- List<XWPFParagraph> paragraphs = document.getParagraphs();
- int count = 0;
- for (XWPFParagraph para : paragraphs) {
- count++;
- System.out.println(para.getText());
- }
- System.out.println("No. of lines : "+count);
- JT_LinesCount.setText(Integer.toString(count));
- fis.close();
- }catch (Exception ex) {ex.printStackTrace(); }
- }
- }
- }
- int charCount = 0;
- charCount += para.getText().length();
Add Comment
Please, Sign In to add comment