checking disk space

Z

zero

hi all,

does any of you know how to check the available space on a storage device
(eg a hard disk) through Java?

TIA

zero
 
T

Thomas Hawtin

zero said:
does any of you know how to check the available space on a storage device
(eg a hard disk) through Java?

Java SE 6 will have File.getUsableSpace and getFreeSpace, which will
give the number of usable/free bytes on the partition of a file (or the
partition it would be on were it to exist).

Tom Hawtin
 
Z

zero

Java SE 6 will have File.getUsableSpace and getFreeSpace, which will
give the number of usable/free bytes on the partition of a file (or
the partition it would be on were it to exist).

Tom Hawtin

So basically in 1.5 there's no way? Oh well, I'll find a way around it.
Thanks :)
 
M

Malte

zero said:
hi all,

does any of you know how to check the available space on a storage device
(eg a hard disk) through Java?

TIA

zero

exec df and pipe output to a file. Read the file. Should give you an
approximate number.

Don't know the Windows equivalent of df.
 
N

None

I submitted an addition to Jakarta Commons IO to do this in a
cross-platform manner. It is currently in SVN trunk and is slated to
be included in the next official release. Until then, here is a
direct link to the source in the SVN repository. Being under ASL 2.0
licensing terms, you can grab it and use it any way you want.

http://svn.apache.org/viewcvs.cgi/j...e/commons/io/FileSystemUtils.java?view=markup

Until 6.0 is out anyway, this is a fairly nice solution.

Frank
 
Z

zero

I submitted an addition to Jakarta Commons IO to do this in a
cross-platform manner. It is currently in SVN trunk and is slated to
be included in the next official release. Until then, here is a
direct link to the source in the SVN repository. Being under ASL 2.0
licensing terms, you can grab it and use it any way you want.

http://svn.apache.org/viewcvs.cgi/jakarta/commons/proper/io/trunk/src/j
ava/org/apache/commons/io/FileSystemUtils.java?view=markup

Until 6.0 is out anyway, this is a fairly nice solution.

Frank

Now that looks like a useful class. Thanks :)
 

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,057
Latest member
KetoBeezACVGummies

Latest Threads

Top