aspose file tools*
The moose likes Beginning Java and the fly likes Size of File Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Size of File" Watch "Size of File" New topic
Author

Size of File

Fisher Daniel
Ranch Hand

Joined: Sep 14, 2001
Posts: 582
Dear all,
How can I get the size of a folder ?
thanks
daniel
Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
I'm not sure if this is exactly what you're looking for, but I was able to come up with the size of all the files within a directory by using a recursive function, like this:

I'm not really sure if there is an easier way to do this or not, but it seems that simply calling the length method on a File object that represents a directory simply returns 0. Therefore, I had to look at each file individually and recurse through any subdirectories. The final result printed the size of all of the files contained within the directory C:\test in bytes.
I hope this helps you out.
Corey


SCJP Tipline, etc.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Size of File
 
Similar Threads
enlaring input box
BackgroundPanel.java cannot be placed in BorderLayout.NORTH
Is JDK same for all platforms(windows,unix,mac) or is it different for different operating systems.
WA #1.....word association
Dateformat problem in iBatis