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
- method does not take any parameter
- long - the number or unallocated bytes on the partition
- SecurityException - if a security manager throw en error
3.1. The program that checks the free space of the main Linux partition under
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.