Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

number of lines in a document

 
Anil Sadineni
Greenhorn
Posts: 20
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7610
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
 
Mark Herschberg
Sheriff
Posts: 6037
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 7610
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 20
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic