1. Introduction
The getFreeSpace() method returns the number of unallocated bytes in the partition. The result is not guaranteed but should be treated as a hint. It is most likely that getFreeSpace()
returns the accurate value immediately after this call.
2. Method signature
Parameters:
- method does not take any parameter
Returns
- long - the number or unallocated bytes on the partition
Throws
- SecurityException - if a security manager throw en error
3. Examples
3.1. The program that checks the free space of the main Linux partition under /dev/sbdb2
The output:
4. Conclusion
In this short article, we presented the File.getFreeSpace()
method with a simple example of how to use it in a real-life situation. This method gave the most accurate value a moment after the call, but in most cases, the result should be treated as a hint.
{{ 'Comments (%count%)' | trans {count:count} }}
{{ 'Comments are closed.' | trans }}