JConfig is a cross-platform JAVA extension tool that can transparently call the underlying system commands to obtain more system information such as disk capacity and remaining space.
JConfig is: http://www.simtel.net/product.download.mirrors.php? Id = 54577. After decompression, extract a series of values under samizdat \ common. copy the dll file to the directory % JAVA_HOME % \ jre \ bin. JConfig determines which dynamic link library to load based on the system name, Java Virtual Machine Type, Java version number, and other information, introduce the samizdat \ common \ JConfig.zip package in the compilation path of the program. The following is an example I wrote:
Java code
Import java. io. File;
Import com. jconfig. DiskObject;
Import com. jconfig. FileRegistry;
Import com. jconfig. Trace;
Public class Spacechecker {
Public static void main (String [] args ){
// This is the path of the folder containing jconfig.htm and jcfactrzz.txt. I copied it to the project.
File file = new File ("jconfig ");
// Initialize the File System
FileRegistry. initialize (file, 0 );
Trace. setDestination (Trace. TRACE_SYSOUT );
// Create a disk object, which can be a disk drive, directory, or file
Try {
DiskObject diskObj = FileRegistry. createDiskObject (
New File ("F: \"), 0 );
// Obtain the disk capacity
Long totalSpace = diskObj. getFile (). getTotalSpace ();
System. out. println (totalSpace/1024/1024/1024/+ "G ");
// Obtain the available disk space
Long freeSpace = diskObj. getFile (). getFreeSpace ();
System. out. println (freeSpace/1024/1024/1024 + "G ");
} Catch (Exception e ){
E. printStackTrace ();
}
}
}