Scroll to top

Read doc file in java using poi

package com.howto;


import org.apache.poi.hwpf.HWPFDocument;

 * Here we will learn how to read a Doc file
public class ReadDocFile {

	public static void main(String args[]) throws IOException {
		 * Create input stream of the doc file - Provide exact path of the doc
		 * file to read
		FileInputStream fistream = new FileInputStream(
		HWPFDocument document = new HWPFDocument(fistream);

		System.out.println("Length of docment is :"
				+ document.characterLength());






Here we will use POI open source project to read windows doc file. PoI Jar will be required that can be downloaded from apache website.

Author avatar


  1. tjuno

    Short and simple..thank you very much

  2. Puja

    what if we want to embed this code in javascript ? how should we do it then ?

  3. anup

    its working or not..

Post a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.