Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes I/O and Streams and the fly likes File properties Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "File properties" Watch "File properties" New topic

File properties

Ransika deSilva
Ranch Hand

Joined: Feb 18, 2003
Posts: 524
Could you please tell me how to get the properties of a File,Folder. I want to get the specially the File/Folder size etc.
Thank you...

SCJP 1.4, SCMAD 1.0<br />SCWCD, SCBCD (in progress)
Ali Gohar
Ranch Hand

Joined: Mar 18, 2004
Posts: 572
See the File class specification from

You can get the size of the file using File class object

File f = new File("test.txt");
long size = f.length();
Dirk Schreckmann

Joined: Dec 10, 2001
Posts: 7023
Moving this to the I/O and Streams forum...

[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
subject: File properties
It's not a secret anymore!