File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes number of lines in a document Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "number of lines in a document" Watch "number of lines in a document" New topic
Author

number of lines in a document

Anil Sadineni
Greenhorn

Joined: Feb 06, 2001
Posts: 20
Hi All,
How can I find out the number of lines in a Microsoft word document file. Is it possible through java? How can I get the number of lines in it. If any one knows the solution, please give the reply for this.
thank you
Anil
murali kante
Greenhorn

Joined: Nov 09, 2001
Posts: 9
Anil,
Try java.io.* package. There are plenty of classes to manipulate.
Initially, u get the file object and pass it FileInput Stream and try using class named LineNumberReader....and methods thereof
Cheers
Murali
Originally posted by Anil Sadineni:
Hi All,
How can I find out the number of lines in a Microsoft word document file. Is it possible through java? How can I get the number of lines in it. If any one knows the solution, please give the reply for this.
thank you
Anil

dickster
Greenhorn

Joined: Nov 12, 2001
Posts: 9
short answer:
no
long answer:
maybe, but not likely.
here's why.
the # of lines in a word*.doc is relative.
why do you even want to do this? you ask a lot of questions...
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610

why do you even want to do this? you ask a lot of questions...

Dickster,
I think Anil's right to ask that question (even a lot of them) is very legitimate !!! Anyway, that's what Javaranch is out there for !
If Anil wants to count the lines of Word documents, it's his problem and we are free to help him or not!


------------------
Valentin Crettaz
Sun Certified Programmer for Java 2 Platform


SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[Blog] [Blogroll] [My Reviews] My Linked In
Mark Herschberg
Sheriff

Joined: Dec 04, 2000
Posts: 6037
Originally posted by Anil Sadineni:
Hi All,
How can I find out the number of lines in a Microsoft word document file. Is it possible through java? How can I get the number of lines in it. If any one knows the solution, please give the reply for this.

Yes you can, but it's not easily. Using the java.io package you can access the file and read in the data, as murali suggested. However, you're on your own to parse the data to determine what the lines are. This means you need to find out what the file enocding is, remove the document information so you just have the content, and then you must parse the content. That's probably not so easy.
(Actually, I think the number of lines might be some document data stored in the word file, so maybe you only need to figure out what the encoding is, and then just look for that piece of data.)

--Mark
dickster
Greenhorn

Joined: Nov 12, 2001
Posts: 9

you ask a lot of questions...

Oops, sorry, this actually was a rhetorical question to myself as I tried to figure out if there is a really easy way to do this, and I can't see it (numlines is part of the stats in the *.doc's properties)...
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
maybe http://www.redbrick.dcu.ie/~bob/Tech/wword8.html may help
I saw some mentions to "line numbers" so it might be worth investigating the link !
HIH
------------------
Valentin Crettaz
Sun Certified Programmer for Java 2 Platform

[This message has been edited by Valentin Crettaz (edited November 13, 2001).]
Anil Sadineni
Greenhorn

Joined: Feb 06, 2001
Posts: 20
Thank you very much for all your replies,
The problem with .doc file is with its format. If we can communicate with 'com' object written in vb or vc, the problem may be solved. But I don't know how to communicate wuth COM object. Please help me regarding this.
thakns again to all

Anil
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: number of lines in a document