How to find the available free space in a system using java

A

akhila

is there a way of finding the hdd space, free space ,temp space
and swap space etc using java ? since the system class of java
corresponds only to the jvm, how does one actually get hold of the
system info...is there an OS dependent way of doing it ? supposing my
OS is Linux what how can i get this info?
 
T

Thomas Hawtin

akhila said:
is there a way of finding the hdd space, free space ,temp space
and swap space etc using java ? since the system class of java
corresponds only to the jvm, how does one actually get hold of the
system info...is there an OS dependent way of doing it ? supposing my
OS is Linux what how can i get this info?

From 1.6 there will be java.io.File.getFreeSpace and getUsableSpace.
Before that you are left with the choice of using JNI or Runtime.exec.

Tom Hawtin
 
A

Adam Warner

From 1.6 there will be java.io.File.getFreeSpace and getUsableSpace.
Before that you are left with the choice of using JNI or Runtime.exec.

akhila may enjoy reading one of Sun's most infamous bug reports:
<http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4057701>

The last comment may be helpful:

Submitted On 10-JAN-2006

[by pi10t]

hi!

if you don't want to wait Java 6 you may use Jakarta Project Commons IO
library. It provides one class with the function of retrieving the free
space on a disk.

http://jakarta.apache.org/commons/io/description.html

Regards,
Adam
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top