Reading Microsoft Word Document in JAVA

Hi friends,
im using follwing code to read word document in java using apache poi package..
import org.apache.poi.poifs.filesystem.*;
import org.apache.poi.hwpf.*;
import org.apache.poi.hwpf.extractor.*;
import java.io.*;
public class readDoc
public static void main( String[] args )
String filesname = "Hello.doc";
POIFSFileSystem fs = null;
try
fs = new POIFSFileSystem(new FileInputStream(filesname;
//Couldn't close the braces at the end as my site did not allow it to close
HWPFDocument doc = new HWPFDocument(fs);
WordExtractor we = new WordExtractor(doc);
String[] paragraphs = we.getParagraphText();
System.out.println( "Word Document has " + paragraphs.length + " paragraphs" );
for( int i=0; i<paragraphs .length; i++ ) {
paragraphs[i] = paragraphs.replaceAll("\\cM?\r?\n","");
System.out.println( "Length:"+paragraphs[ i ].length());
catch(Exception e) {
e.printStackTrace();
but im getting exception that
java.io.IOException: Unable to read entire header; -1 bytes read; expected 512 bytes
at org.apache.poi.poifs.storage.HeaderBlockReader.<in it>(HeaderBlockReader.java:78)
at org.apache.poi.poifs.filesystem.POIFSFileSystem.<i nit>(POIFSFileSystem.java:83)
how to solve this issue.. please suggest me .. its urgent..
Add to satheeshtech's Reputation

You might do better consulting [http://www.nabble.com/Apache-POI-f298.html|http://www.nabble.com/Apache-POI-f298.html] .

Similar Messages

  • Can an ipad read microsoft word documents

    Can an iPad read Microsoft Word documents?

    You only need those apps if you wish to create/edit Word documents.

  • Can JAVA read Microsoft word document?

    Hi
    I am trying to make a program that read a word document, and split the document in to each pages and save each pages with file as it's footer of each pages.
    --- example-----
    test.doc
    Page 1 |
    |
    |
    |
    |
    |
    footer - hi |
    Page 2 |
    |
    |
    |
    |
    |
    footer - test |
    Page 3 |
    |
    |
    |
    |
    |
    footer - still |
    Page 4 |
    |
    |
    |
    |
    |
    footer - hahaha |
    Page 5 |
    |
    |
    |
    |
    |
    footer - lastpage |
    -----------------------> Out put of the program
    hi.doc , test.doc, still.doc, hahaha.doc, lastpage.doc
    Is there any way to import word document and process like that above?
    I have searched about this, and found out 'Jakarta POI' can access to word document but with many restrictions. (I heard it doesn't support word version 2003 and 97)
    Can any one please answer this?
    Thankx

    I'm not really sure that java is the best language to use for this particular project. I haven't looked into writing a standalone application to do this sort of thing, but Microsoft Word has a built in VB editor that allows you to write scripts that will do this very simply, using Word's Document Object Model.
    I would imagine the same sort of the thing could be done from a Stand-alone aplication as well, but you might need some libraries for reading the document and obtaining the object with the same model. I would look into Microsoft's .net solutions for this one. You might even be able to work out a solution in C++, C#, or even J# (which I understand is "similar" to java), if you don't know visual basic.
    It is possible that there is a library out there that will read a Word Document, and create the appropriate Java object with the same object model, but I don't know where it can be found.
    Anyway, if the option is available to you, take a look at Microsoft's .Net. You'll probably have more luck that way. Good Luck!

  • API FOR READING MICROSOFT WORD DOCUMENT FILE

    HELLO
    I need to know are there any api's to read a word document i.e a .doc file into a java program. If there r api where can i find them & how can i use them

    For Reading PDF documents, you can use PDFBox, for reading word documents, Apache's POI . But POI supports only Excel right now, Word will soon be supported

  • When I download Microsoft word documents (if have word 2007), I have somehow changed the settings and it downloads them in wordpad, and the format is very bad and I can't read a lot of the document. How do I change the default setting back to using Micro

    When I download Microsoft word documents (if have word 2007), I have somehow changed the settings and it downloads them in wordpad, and the format is very bad and I can't read a lot of the document. How do I change the default setting back to using Microsoft Word 2007 to open these documents?
    == This happened ==
    Every time Firefox opened
    == about a few weeks ago - I had tried to open some docuuments saved on a mac, my PC (which runs Windows 7), used word pad to open these, and this seems to have changed the default settings somehow.

    See this:
    [http://support.mozilla.com/en-US/kb/Managing+file+types]

  • Api POI read and replace my word document with java

    Hi
    Everyone
    I�d like to know if someone has a piece of code reading a word document with api POI to send me?
    I need read replace the word document wiht java j2ee.
    Thanks

    Hello,
    You have to use the Office Integration Library. Please, follow the documentation below:
    http://help.sap.com/saphelp_nw04/helpdata/en/c3/32853febec3c17e10000000a114084/frameset.htm
    I hope this helps you.
    Regards,
    Blanca

  • Searching a string in Microsoft word from a Jav Application

    Would appreciate if you could provide me with an example/ suggestion to search for a string in Microsoft Word document from a java aplication. Thanks

    Short and rude answer: STFW.
    Long and polite answer: If you use "java apache word excel" as the criterium to search the web with Google, the first hit is what we are looking for:
    http://jakarta.apache.org/poi/
    Good luck anyway!

  • HOW TO OPEN WORD DOCUMENT FROM JAVA???

    hi everyone! Can you please help me to come with this problem? Let me to set my main target I want to achieve:
    1) In my program user should first press a button;
    2) Then already created Word Document should be opened (I DO NOT NEED to open that Word Document in Java or something like JField). Just simply it should be opened as a Microsoft Word Document.
    I DO NEED YOUR HELP! PLEASE HELP ME....!

    Running cmd using the exec is also a windows only solution, there is no "more" or "less" it that solution compared to the rundll.
    Since word is a windows format its pretty obvious that the application is ran under windows platform.
    If you are running on a different platform (maybe using open office you can open word documents, i'm not sure) you might want to use the JDIC library (https://jdic.dev.java.net/) which enables you to open/edit/browse such files using the default viewer/editor/browser of the system you are working on.
    Look at the org.jdesktop.jdic.desktop.Desktop object for these methods.
    You can also find the Desktop object in J2SE6 but its still in beta.

  • Printing Microsoft word documents

    Does anybody know how to print MS Word documents in Java.
    I have been able to print normal txt files using Java Print Service in J2SE1.4.

    The short answer is that the Java Print Service that comes with J2SE 1.4 does not contain support for MS-Word documents. I would be surprised if Sun ever offered support for anything from Microsoft. There is support for RTF some support in the J2SE for RTF (take a look at JEditorPane), which is a Microsoft standard, but that's about it. You might want to take a look at the POI project at http://jakarta.apache.org/poi/index.html There is support for working with a few Microsoft Office file formats there.

  • HP Laserjet PRO MFP125nw doesn't print Microsoft Word documents from PC

    Hello.
    I've recently bought a brand new HP Laserjet PRO MFP125nw printer. The functions seemed really nice and the price was acceptable. I've brought it to my home, installed it following the manual, connected it to Wi-Fi etc. It generally works fairly well. PDF files are printed perfectly well, the scaning function works and it's generally a nice piece of technology.
    The only problem is that it just doesn't want to pring Microsoft Word documents from my PC. It prints it perfectly when I try to print .docx from my smartphone using the app, but it doesn't respond when I try doing it from the PC.
    My Office version is 2007 Enterprise. Do you have any idea what I should do?
    Thank you in advance

    Thank you a lot for a quick reply, Cbert. It's fantastic to see HP actually reading their forums and trying to help!
    I'll try plugging it into the wall and directly to the PC with a USB, we'll see if it works out.
    About Word, i've already tried reinstalling Word, even installed a 2003 version to check if it works with that. Well it doesn't. And as i've written before, I tried turning some .docx files to .pdf using a converter, but it still doesn't print them.
    Anyway, i'll try the first two points and keep you updated, thanks!

  • Good day sir, please i just got an iPAD 4 and I have bee having a serious difficulties performing some operations on it of which  was told it is possible one of which is to create a microsoft word documents on my iPAD the second is attaching a file to y e

    Good day sir, please i just got an iPAD 4 and I have bee having a serious difficulties performing some operations on it of which  was told it is possible one of which is to create a microsoft word documents on my iPAD the second is attaching a file to y e mail in order too send Also, I have not been able to safe a download files on my iPAD as I do not have a download manager on it. Please, kindly send to me ways of getting these problems fixed as i am a young resarcher who sends a lot of mails and download as wel. Als, I am always on the move as this has propmted me in the first place to get an IPAD .
    Last but not the list II will equally wish to know if it will be possible for  me to use a pen to take seminar notes on my iPAD and safe the same on my iPAD fr later reference as it is done on other tablets ke samsung. I read somethng like stylus pen but I don't know how far. Please, kindly make an appropriate recommendaton for me and where i can get it. I reside in Turkey and currently a Ph.D stuudent in ine of the leading niversities in the country. Also, I will like to know if you ave ecoonomics text books that I can buy or published journas in apple store because i have searched but could not get  a desirerable ones.
    Once again, thanks for your anticipated prompt rely to my mail.
    Regards
    Wasu Fawole

    Have a look at the following:
    http://itunes.apple.com/sg/app/quickoffice-pro-hd-edit-office/id376212724?mt=8&l s=1
    http://itunes.apple.com/sg/app/office2-hd/id364361728?mt=8&ls=1
    http://itunes.apple.com/sg/app/documents-to-go-premium-office/id317107309?mt=8&l s=1
    http://itunes.apple.com/sg/app/polaris-office/id513188658?mt=8&ls=1

  • How can I change a Microsoft Word document file into a picture file?

    How can I change a Microsoft Word document file into a picture or jpeg file? I am wanting to make the image I created my background on my macbook pro.

    After I had the document image the way I wanted it, I saved it as a web page and went from there. Below are the steps starting after I did the "save as" option in Word:
    1) Select "Save As Web Page". I changed the location from documents to pictures when the window came up to save it as a web page.
    2) Go to "Finder" on you main screen, or if it's on your main toolbar at the bottom.
    3) Click on the "Pictures" tab and find the file you just re-saved as a web page. (I included "web page" or something similar in the new title so I could easily find the correct file I was looking for)
    4) Open the correct file and then "right click" on the actual image. (Use 2 fingers to do so on a Mac)
    5) Select 'Use Image As Desktop Picture", and voilà! The personally created image, or whatever it is that you wanted, is now your background.
    **One problem I encountered while doing this is that the image would show up like it was right-aligned in relation to the whole screen. The only way I could figure how to fix this was to go back to the very original document in Word, (the one before it was saved as a web page), and move everything over to the left.
    I hope this helps someone else who was as frustrated as I was with something that I thought would have been very simple to do! If you have any tips or suggestions of your own, please feel free to share. : )

  • Integrating Microsoft Word documents with ADF BC and JClient technologies

    Hi,
    We are developing a Police Management System in JAVA with the Oracle Jdeveloper 10.1.2.0.0. We are using for the access to the data, in the businesses tier, the ADF Business Component Technology and for the User Interface, in the client tier, the JClient for ADF Technology. The used Database is Oracle Enterprise Edition 10.1.0.3.0. with the intermedia option.
    We were looking for ways to upload and insert Microsoft Word Documents into a view object using JClient on the client tier. We have found the following options:
    1) Oracle Intermedia database datatype ORDSYS.ORDDOC and their corresponding ADF Business Compomnents domains -> The problem is using Jclient on the client tier. In Oracle JDeveloper 10g, developers will not be able to create new applications using JClient interMedia controls. JUImage (limited to images only) is the JClient control available to access multimedia in the database.
    2) Oracle COM Automation Feature -> We were studying the possibility to built a solution with Oracle and Microsoft Word using Oracle COM Automation Feature for Java. The problem is Oracle COM Automation Feature requires Windows NT, Windows XP, Windows 2000, or Windows Server 2003. We are using a database on linux, therefore this option is not valid.
    3) CLOBs in database and theirs corresponding ADF Business Components domains -> But I don't know how to use ADF BC objects in JClient tier.
    Can someone please help?
    Thanks,
    Patri

    Hi,
    I have worked with BLOBS or CLOBS and their corresponidng ADF Business Components domains, but I don't know how to use ADF BC objects in JClient tier.
    To sum up, I want to upload, insert and view microsoft word documents by using a JClient application using ADF/BC4J components.
    Thanks,
    Patri

  • CAN'T OPEN MICROSOFT WORD DOCUMENTS AFTER DOWNLOADING MAVERICK

    I downloaded Maverick OS X 10.9.3 and now I can't open my Microsoft Word documents!  HELP!!
    The message I receive when trying to open a document read:  You can't open the application "Microsoft Word" because PowerPC applications are no longer supported.
    I wish I knew this before I upgraded to Maverick.  It happened to my iphotos as well but after purchasing new software for iphoto, I have been able to retrieve my photos. 
    I hope I don't have to do the same for my documents.
    Thanks

    I wouldn't recommend buying the boxed version of Office 2011. A new version of Office is coming out in a few months and you'll be stuck with old software. The next version of Office will be subscription only. You can buy Office 365 now and it will automatically upgrade you for free when the new version comes out. This is a monthly fee.
    If paying monthly is not an option for you, you can also look at buying Office 2008. While it's End of Life software like Office 2004 (this means it will receive no further updates) it will run in Mavericks with only a few minor glitches. You might be able to buy Office 2008 at a more reasonable price. Otherwise I would like at LibreOffice or OpenOffice that Esquared mentioned above.

  • Create Word document with Java

    I want to create a Word Document with Java. But I don't know how can I insert text in a Word document.

    I searched and found JXWord (probably limited to Windows): http://www.geocities.com/picmapicma/
    I'm interrested to know if it works fine...:)

Maybe you are looking for

  • EXCISE AND CIN SEZ AND DTA

    We are having one company code where the plant is SEZ AND ALL THE ENTRIES ARE DONE TAKING SEZ BENEFIT. i AM HAVING QUERY ,IS IT POSSIBLE THAT SINGLE PLANT CAN BE RECONGNISED AS SEZ FOR CAPEX ENTRIES AND DTA FOR DTA RELATED ENTRIES REGARDS,

  • Using more than one skin

    I have 2 different areas on my site that I am using ADDT for. One is a web site admin area, and one is a public area. Both require log in access. My problem is that I would like to use different skins for each of the 2 areas. When I insert a Dynamic

  • ITunes is asking m to switch to english version.  I HAD english version.  how do I get it back

    I have windows 7 on my hp laptop with iTunes.  When I go to use iTunes it says to switch to English veersion.  I have always had the English version.  How can I remedy this situation because it is unusuable as it is?

  • Color/saturation shift in FCPX 10.1

    I've been using Resolve to color grade my footage , render to Prores 422 (hq) and then import it into FCPX. I noticed that there is a distinct difference in the color and saturation of the footage when viewed in Resolve and FCPX (or QuickTime) .  I i

  • Can't sync after re-installing computer software

    I had to re-install software on my computer after it locked me out. I removed my IPod from my Apple I.D. under my account in ITunes due to re-naming my computer. Now, my IPod Classic will not sync. It shows up under my computer and even shows in ITun