File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Disk space checking Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Disk space checking" Watch "Disk space checking" New topic

Disk space checking

Gopu Akraju
Ranch Hand

Joined: Jan 13, 2008
Posts: 242
I am opening few files, and after some string manipulation, concatenating them into one .txt file and write it to a output file. I would like to know whether there is any way to check the disk space available in the output directory before I store the output file and give proper info to the user whether the file is saved or not. How do I check the disc space available in the output directory. How to handle such scenario? Thanks.
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902


this ll help..

[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
Mark Vedder
Ranch Hand

Joined: Dec 17, 2003
Posts: 624

Take a look at the File class' getFreeSpace() and getUsableSpace() methods. Note that these were added in Java 6, so they are not available in earlier versions.
[ April 04, 2008: Message edited by: Mark Vedder ]
I agree. Here's the link:
subject: Disk space checking