Java and Drive Space

Posted on 2004-10-20
Last Modified: 2010-03-31
Is there anyway to find out the size of a disk and free space on the drive?

I have seen some examples of how to do this by creating temp files on the drive ( I though this was a bit bad )
Does anyone know if it can be done?

Question by:ice_nin
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 37

Expert Comment

ID: 12359602
You could execute a dir command (windows) and parse the output
LVL 86

Expert Comment

ID: 12359604
You could

Runtime.getRuntime().exec.("cmd.exe /C dir");
LVL 24

Expert Comment

ID: 12360645
Restriction: an empty disk returns an error message so the parsing gets complex.
I wonder why getenv() finally is incorporated into JAVA 5 and something universal like this is not.
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 12443491
is there not a universal way of checking, because my application is going to be run over several platforms ( not just windows )
LVL 37

Accepted Solution

zzynx earned 125 total points
ID: 12443609
LVL 37

Expert Comment

ID: 12443619
This indicates it IS possible (but maybe not that straightforward ;°)
LVL 37

Expert Comment

ID: 12443784

Author Comment

ID: 12443789
Thanks for all the help

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
numbers ascending pyramid 101 264
spring jars download 1 68
Setup GlassFish 4 55
listing all the respondents to a twitter feed - Java 5 47
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Suggested Courses

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question