|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.backsource.alert.util.Drive
Represent a drive/partition in the filesystem.
A drive is a simple representation of a partition/harddisk/filesystem that is available on the computer. Through it one can get the partition/harddisk name, such as /dev/hda1 or C:, or the file system name, such as / or C:. The total size and how much of it that is used is also available as bytes.
The only way to get one or more Drives is through the two static methods: getDrives() and getDrive(String driveName).
Currently this is done through the use of the external command df, which is supported on LINUX, FreeBSD, Mac OS X and Windows plattforms wich has CYGWIN installed.
// Get a single drive
Drive d = Drive.getDrive("/");
if ( d.percentUsed() > 93) {
System.err.println("Diskspace is soon full for normal users, percent used = " + d.percentUsed()+"%");
} // end of if ()
// Get all drives
Drive[] d = Drive.getDrives();
Depends on: log4j.jar
| Method Summary | |
protected static Drive[] |
df(java.lang.String drive)
Run the df command an create drives. |
protected static Drive |
dir(java.io.File drive)
Dir emultion on win with df installed. |
static Drive |
getDrive(java.lang.String driveName)
Get a drive by its name, may be either device name or mount point name. |
protected static Drive |
getDriveFromDf(java.lang.String line)
Parse a df line output and instantiate a Drive from it. |
java.lang.String |
getDriveName()
Get the name of the device. |
static Drive[] |
getDrives()
Get all drives available on the system. |
protected static Drive[] |
getDrives(java.lang.String driveName)
main entry for internal methods, delegates to correct os methods. |
java.io.File |
getFile()
Get a file represenation of device, i.e filsystem mounted on device. |
int |
getPercentUsed()
Get percent of disk used. |
long |
getSize()
Get size of device in bytes. |
long |
getUsed()
Get number of bytes used. |
protected static Drive[] |
getWinDrives(java.lang.String drive)
Entry for windows. |
protected static boolean |
hasCygwin()
Check if system has Cygwin installed (does a uname). |
static void |
main(java.lang.String[] args)
|
java.lang.String |
toString()
Get a string rep of device, looking like a df line. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Method Detail |
public java.lang.String getDriveName()
public long getSize()
public long getUsed()
public int getPercentUsed()
public java.io.File getFile()
public java.lang.String toString()
public static Drive getDrive(java.lang.String driveName)
throws java.io.IOException
java.io.IOException
public static Drive[] getDrives()
throws java.io.IOException
java.io.IOException
protected static Drive[] getDrives(java.lang.String driveName)
throws java.io.IOException
java.io.IOException
protected static Drive[] df(java.lang.String drive)
throws java.io.IOException
drive - get single drive (by device name or file system name) or if null all drives.
java.io.IOExceptionprotected static Drive getDriveFromDf(java.lang.String line)
protected static Drive[] getWinDrives(java.lang.String drive)
throws java.io.IOException
Does not use df directly since cygwin df emulates a lot of extra drives to help unix commands. The file system will be constructed from the driveName.
java.io.IOException
protected static Drive dir(java.io.File drive)
throws java.io.IOException
java.io.IOExceptionprotected static boolean hasCygwin()
public static void main(java.lang.String[] args)
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||