au.com.asmanit.utility
Class DirSizer

java.lang.Object
  extended byau.com.asmanit.utility.DirSizer

public class DirSizer
extends java.lang.Object

This class determines the size of a given directory. Copyright 2005 Asman IT Consulting

Author:
David Asman

Constructor Summary
DirSizer()
          Generate a DirSizer without specifying the directory - a directory must be specified before getDirSize() can be called.
DirSizer(java.io.File dir)
          Generate a DirSizer supplying the directory as a file.
DirSizer(java.lang.String dirName)
          Generate a DirSizer supplying the directory as a string.
 
Method Summary
 java.io.File getDir()
          Returns the directory that will be measured
 long getDirSize()
          Return the size of the chosen directory's contents.
 boolean isFollowSymlinks()
          Return whether the DirSizer will follow symlinks when sizing a directory
 void setDir(java.io.File dir)
          Set the directory to be measured.
 void setFollowSymlinks(boolean followSymlinks)
          Set whether the DirSizer should follow symlinks when sizing a directory.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DirSizer

public DirSizer()
Generate a DirSizer without specifying the directory - a directory must be specified before getDirSize() can be called.


DirSizer

public DirSizer(java.lang.String dirName)
Generate a DirSizer supplying the directory as a string.

Parameters:
dirName - The name of the directory
Throws:
java.lang.IllegalArgumentException - if the directory does not exist

DirSizer

public DirSizer(java.io.File dir)
Generate a DirSizer supplying the directory as a file. If null is supplied, a directory must be specified before getDirSize() can be called.

Parameters:
dir - The file representing the directory
Throws:
java.lang.IllegalArgumentException - if the directory does not exist
Method Detail

getDir

public java.io.File getDir()
Returns the directory that will be measured

Returns:
a File representing the directory to be measured

setDir

public void setDir(java.io.File dir)
Set the directory to be measured.

Parameters:
dir - The directory to measure
Throws:
java.lang.IllegalArgumentException - if the directory does not exist

isFollowSymlinks

public boolean isFollowSymlinks()
Return whether the DirSizer will follow symlinks when sizing a directory

Returns:
true if the DirSizer follows symlinks

setFollowSymlinks

public void setFollowSymlinks(boolean followSymlinks)
Set whether the DirSizer should follow symlinks when sizing a directory.

Parameters:
followSymlinks - the value of the "follow symlinks" option

getDirSize

public long getDirSize()
Return the size of the chosen directory's contents.

Returns:
the size of the directory's contents, in bytes