Java tutorial
//package com.java2s; //License from project: Apache License import java.io.File; public class Main { public static long getFreeSpace(String path) { File file = new File(path); if (!(file.isDirectory() && file.exists())) { file.mkdirs(); if (file.isDirectory()) { return file.getFreeSpace(); } else { return 0L; } } else { return file.getFreeSpace(); } } }