Java file
Obtains the size of the specified directory space.
Import java. io. File;
Public class SpaceChecker {
Public static void main (String [] args ){
File [] roots = File. listRoots ();
For (int I = 0; I <roots. length; I ++ ){
System. out. println (roots [I]);
System. out. println ("Free space =" + roots [I]. getFreeSpace ());
System. out. println ("Usable space =" + roots [I]. getUsableSpace ());
System. out. println ("Total space =" + roots [I]. getTotalSpace ());
System. out. println ();
}
}
}
Get directory space
Import java. io. File;
Public class SpaceChecker {
Public static void main (String [] args ){
File [] roots = File. listRoots ();
For (int I = 0; I <roots. length; I ++ ){
System. out. println (roots [I]);
System. out. println ("Free space =" + roots [I]. getFreeSpace ());
System. out. println ();
}
}
}
Get space
Import java. io. File;
Public class SpaceChecker {
Public static void main (String [] args ){
File [] roots = File. listRoots ();
For (int I = 0; I <roots. length; I ++ ){
System. out. println (roots [I]);
System. out. println ("Usable space =" + roots [I]. getUsableSpace ());
System. out. println ();
}
}
}
Retrieve total space
Import java. io. File;
Public class SpaceChecker {
Public static void main (String [] args ){
File [] roots = File. listRoots ();
For (int I = 0; I <roots. length; I ++ ){
System. out. println (roots [I]);
System. out. println ("Total space =" + roots [I]. getTotalSpace ());
System. out. println ();
}
}
}