November 2004
Intermediate to advanced
400 pages
10h 31m
English
You need to know the size of everything contained within a directory.
Use the
sizeOfDirectory( )
method on FileUtils. The following example returns
the size of the temp directory:
File dir = new File( "temp" ); long dirSize = FileUtils.sizeOfDirectory( );
If temp contains a number files,
FileUtils.sizeOfDirectory( ) will return the sum
of the size of every file in temp. If
temp contains subdirectories, this method will
recursively call sizeOfDirectory( ) on each
subdirectory to obtain the size of each subdirectory, and it will
return the sum of these sizes.
Read now
Unlock full access