How to find the Directory size including sub directories
How to find the Directory size including sub directories
Is there and predefined methods...
if not please send me the efficent java code to find the
diorectory size(imp: it should include the subdirectory)
[217 byte] By [
Abdul] at [2007-11-9 22:30:44]

# 1 Re: How to find the Directory size including sub directories
Abdul,
You can write a recursive method that traverses a directory tree structure.
Check out the file object in the JDK documentation.
Good luck,
Rob Abbe
"Abdul" <rahuman_k@yahoo.com> wrote:
>
>
>How to find the Directory size including sub directories
>Is there and predefined methods...
>if not please send me the efficent java code to find the
>diorectory size(imp: it should include the subdirectory)
# 2 Re: How to find the Directory size including sub directories
"Abdul" <rahuman_k@yahoo.com> wrote:
>
>
>How to find the Directory size including sub directories
>Is there and predefined methods...
>if not please send me the efficent java code to find the
>diorectory size(imp: it should include the subdirectory)
public static long dirSize(File dir)
{
if (dir.isFile())
return dir.length();
File[] files = dir.listFiles();
long size = 0;
if (files != null)
{
for (int i = 0; i < files.length; i++)
size += dirSize(files[i]);
}
return size;
}
lekhak at 2007-11-11 23:01:49 >

# 3 Re: How to find the Directory size including sub directories
"lekhak" <junkdallas@yahoo.com> wrote:
>
>"Abdul" <rahuman_k@yahoo.com> wrote:
>>
>>
>>How to find the Directory size including sub directories
>>Is there and predefined methods...
>>if not please send me the efficent java code to find the
>>diorectory size(imp: it should include the subdirectory)
>
>public static long dirSize(File dir)
>{
> if (dir.isFile())
> return dir.length();
> File[] files = dir.listFiles();
> long size = 0;
> if (files != null)
> {
> for (int i = 0; i < files.length; i++)
> size += dirSize(files[i]);
> }
> return size;
>}
jly at 2007-11-11 23:02:49 >
