

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Get the usable space of this partition in Java
The method java.io.File.getUsableSpace() is used to obtain the usable space in the form of bytes for the virtual machine on the partition specified by the required abstract path name. This method requires no parameters and it returns the bytes for the virtual machine on the partition.
A program that demonstrates this is given as follows −
Example
import java.io.File; public class Demo { public static void main(String[] args) { File[] roots = File.listRoots(); try { for(File r : roots) { System.out.println(r); System.out.println("Usable space = " + r.getUsableSpace()); } } catch(Exception e) { e.printStackTrace(); } } }
The output of the above program is as follows −
Output
C:\ Usable space = 317685366784 D:\ Usable space = 83022270464 E:\ Usable space = 23645868032 F:\ Usable space = 0
Note − The output may vary on Online Compilers.
Now let us understand the above program.
The method java.io.File.getUsableSpace() is used to obtain the usable space in the form of bytes. A code snippet that demonstrates this is given as follows −
File[] roots = File.listRoots(); try { for(File r : roots) { System.out.println(r); System.out.println("Usable space = " + r.getUsableSpace()); } } catch(Exception e) { e.printStackTrace(); }
- Related Questions & Answers
- Get the free space of this partition in Java
- Get the total space of this partition in Java
- Get the ID of this timezone in Java
- Java Program to get the number of hours in this duration
- Java Program to get the number of minutes in this duration
- How to get the children of $(this) selector?
- Python Pandas CategoricalIndex - Get the categories of this categorical
- How to get the children of the $(this) selector in jQuery?
- Python Pandas CategoricalIndex - Get the category codes of this categorical
- Python Pandas - Get the Integer number of levels in this MultiIndex
- What are the uses of this keyword in java?
- Make your Web Application more Usable!
- How to get the number of siblings of this node in a JTree?
- This keyword in Java
- Get the hash code for this instance in C#
Advertisements