How to check the disk space in java

In this section we will be showing a java source code to check disk space on a specified partition. Both the total disk space available and total disk space will be shown on this source code. The idea is to check the disk space using the File class. The abstract filename declared on the File constructor will be the basis of what is the partition to be checked.

Running the source code above on my machine produces the following output: