Home Java Java-get-example Java Get Free Space



Java Get Free Space
Posted on: October 24, 2008 at 12:00 AM
In this section, you will study how to obtain available free space in the specified file. In the given example, we have provided the path of file 'Hello.txt' to the constructor of class File.

Java Get Free Space

     

In this section, you will study how to obtain available free space in the specified file. In the given example, we have provided the path of file 'Hello.txt' to the constructor of class File.

file.getFreeSpace()- returns the number of unallocated bytes of the file.

Here is the code of GetFreeSpace.java

import java.io.File;  
  
  public class GetFreeSpace  {  
  public static void main(String[] args){  
  File file = new File("C:\\Hello.txt");  
  long value = file.getFreeSpace();  
  System.out.println("Total free space available in the file is "+value+" B");  
 }  
 }  

Output will be displayed as:

 

Download Source Code

 

Related Tags for Java Get Free Space:
cfileideclassconstructorpathiostructfreeconstvithisidaiiftxtieexamplestudytoexamcieilspacesectionpeceinasmtraceclspechowprotorxaxampsspctoreeatpacishellohallivmplconsstrxtvassthavstabablhelloctopleplprono


More Tutorials from this section

Ask Questions?    Discuss: Java Get Free Space  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.