Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Beginning Java and the fly likes Find File Size Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Find File Size" Watch "Find File Size" New topic
Author

Find File Size

Natesan Prabhakaran
Ranch Hand

Joined: Jul 11, 2006
Posts: 47
hi..

I need to find .pdf and .eps(encapsulated post script) file size but i cant., can you anyone help me.

thanks
Prabhakaran.N


Regards,
Prabhakaran.N
Dave Jones
Ranch Hand

Joined: Feb 20, 2005
Posts: 77
Hi
If you have the file name, then you can check the possibilities of the 'File ' class.
Muhammad Saifuddin
Ranch Hand

Joined: Dec 06, 2005
Posts: 1321

length() method of File Class is return the file size in bytes.
See Java Doc for more clarification. or try google for it. you'll definitely find some example on it.


Saifuddin..
[Blog][Linkedin] How To Ask Questions On JavaRanch My OpenSource
Natesan Prabhakaran
Ranch Hand

Joined: Jul 11, 2006
Posts: 47
hi..thanks for reply.,

all "File" related funtions tell about lengh of file like

System.out.println("File size = " +new
File("D:\\NPrabhakaran\\Important.doc").length());
Natesan Prabhakaran
Ranch Hand

Joined: Jul 11, 2006
Posts: 47
hi Saif,

but it is not working for .pdf and .eps files.

thanks.
Muhammad Saifuddin
Ranch Hand

Joined: Dec 06, 2005
Posts: 1321

Originally posted by Natesan Prabhakaran:
but it is not working for .pdf and .eps files.


try this code..



I have checked this code in my machine and it works fine.
[ September 05, 2007: Message edited by: Saif uddin ]
Natesan Prabhakaran
Ranch Hand

Joined: Jul 11, 2006
Posts: 47
yes Saif,
thank you., now i got.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Find File Size
 
Similar Threads
retrieve a file from a fileinputstream
Find the size of an uploaded file in a servlet.
file uploading using enctype="MULTIPART/FORM-DATA"
Need someones help very quickly with File copying, PLEASE!!
How to get the file length before download