Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: How to read content of Word document ..?

  1. #1
    Junior Member
    Join Date
    May 2014
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post How to read content of Word document ..?

    Hi All


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    6,310
    My Mood
    Mellow
    Thanks
    253
    Thanked 780 Times in 765 Posts

    Default Re: How to read content of Word document ..?

    Welcome to the Forum! Please read this topic to learn how to post code correctly and other useful tips for newcomers.

    Please show what you've tried, and provide more details in your post besides "Hi."

  3. #3
    Junior Member
    Join Date
    May 2014
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: How to read content of Word document ..?

    Hi,
    Thanks for your time, I have tried this and get success. Is there any other better solution

    public static void main(String[] args) {

    File file = new File("D:/Test.docx");
    try
    {
    FileInputStream fis = new FileInputStream(file);
    //POIFSFileSystem poi = new POIFSFileSystem(fis);
    XWPFDocument doc = new XWPFDocument(fis);
    XWPFWordExtractor extractor = new XWPFWordExtractor(doc);

    Scanner scanner = new Scanner(extractor.getText());
    System.out.println(test);
    }
    catch(Exception e)
    {
    e.printStackTrace();
    }

    }

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    22,320
    Thanks
    56
    Thanked 2,374 Times in 2,345 Posts

    Default Re: How to read content of Word document ..?

    Please edit your post and wrap your code with code tags:
    [code=java]
    YOUR CODE GOES HERE
    [/code]
    to get highlighting and preserve formatting.

    get success
    That's good.
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member
    Join Date
    Jul 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: How to read content of Word document ..?

    Hi,
    Can you please let me know what are all the jar files would require for your above code(XWPFDocument)? Because am using the code snippet, but getting run time error like:
    Could not initialize class org.openxmlformats.schemas.wordprocessingml.x2006. main.CTDocument1

    Regards,
    Vimal

Similar Threads

  1. Replies: 1
    Last Post: January 27th, 2014, 12:46 AM
  2. Replies: 3
    Last Post: December 13th, 2013, 07:36 AM
  3. Need Help For Adding image into Word document Using APache POI
    By nareshdev in forum What's Wrong With My Code?
    Replies: 0
    Last Post: June 17th, 2013, 03:44 AM
  4. read a file word by word
    By poornima2806 in forum File I/O & Other I/O Streams
    Replies: 1
    Last Post: February 23rd, 2012, 03:14 PM
  5. How to read an XML document in Java with DOM Parse?
    By JavaPF in forum File Input/Output Tutorials
    Replies: 0
    Last Post: May 20th, 2008, 08:04 AM