List of utility methods to do Disk Free Space Get
long | getFreeSpace(File directory) get Free Space return directory.getUsableSpace() / KILOBYTE;
|
long | getFreeSpace(File file) get Free Space long free = file.getFreeSpace(); while (free == 0) { file = file.getParentFile(); return free; |
long | getFreeSpace(String dir) Returns the free disk space on the partition storing the given directory. return new File(dir).getFreeSpace(); |
long | getFreeSpace(String pathname) get Free Space return (new File(pathname)).getUsableSpace(); |
long | getFreeSpaceOnPartition(File f) Returns the free space on the partion where the specified file is located return f.getUsableSpace();
|
long | getTreeSize(File root) get Tree Size long size = 0; File files[] = root.listFiles(); if (files == null) return size; for (File file : files) { if (file.isDirectory()) size += getTreeSize(file); else ... |
long | getTreeSize(File root) Get the size of a file or a directory tree long size = 0; if (root.isFile()) size = root.length(); else { for (File f : root.listFiles()) { size += getTreeSize(f); return size; |
long | getUnixFreeSpace(String pathname) get Unix Free Space try { String[] command = { "df", "-Pk", pathname }; Process process = Runtime.getRuntime().exec(command); InputStream procOutput = process.getInputStream(); BufferedReader reader = new BufferedReader(new InputStreamReader(procOutput)); reader.readLine(); String line = reader.readLine(); String[] fields = line.split("\\s+"); ... |