commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Niall Pemberton" <niall.pember...@gmail.com>
Subject Re: [io] FileSystemUtils.getDrives?
Date Sun, 29 Oct 2006 14:22:00 GMT
On 10/29/06, Gregor Zeitlinger <gregor@zeitlinger.de> wrote:
> I recently had the problem to find the partition with the most free
> space available.
> FileSystemUtils.freeSpace was not working in that case, because I
> wanted to check all available drives/mount points.
> I solved this problem by using df on Linux and WMI (windows management
> instrumentation) on Windows.
> It would have been easier in the following form:
>
> for(Drive d : FileSystemUtils.getDrives()) {
>   if (d.freeSpace() > maxSpace) {
>     result = d;
>     maxSpace = d.freeSpace();
>   }
> }
>
> Would you be interested in something like that?

What about File.listRoots() ?

  for(Drive d : File.listRoots()) {
    if (d.freeSpace() > maxSpace) {
      result = d;
      maxSpace = d.freeSpace();
    }
  }

Niall

> Gregor Zeitlinger
> gregor@zeitlinger.de

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message