如何找到使用Java留下多少磁盘空间?

问题描述:

如何找到使用Java剩余多少磁盘空间?

How to find how much disk space is left using Java?

只需查看File类文档。这是1.6中的新功能之一。

Just look at the File class documentation. This is one of the new features in 1.6.

这些新方法还包括:


  • public long getTotalSpace()

  • public long getFreeSpace()

  • public long getUsableSpace()

  • public long getTotalSpace()
  • public long getFreeSpace()
  • public long getUsableSpace()

如果您仍在使用1.5,那么您可以使用 Apache Commons IO 库及其 FileSystem类

If you're still using 1.5 then you can use the Apache Commons IO library and its FileSystem class