How do I calculate directory size?

Category: commons.io, viewed: 5183 time(s).
import java.io.File;
import org.apache.commons.io.FileUtils;

public class DirectorySizeSample
{
    public static void main(String[] args)
    {
        // Using FileUtils.sizeOfDirectory() we can calculate
        // the size of a directory including it sub directory
        long size = FileUtils.sizeOfDirectory(new File("C:/Windows"));

        System.out.println("Size: " + size + " bytes");
    }
}
Click here to lend your support to: Kode Java Org and make a donation at www.pledgie.com !

 

Uncensored Newsgroups
Download Hundreds of Complimentary Industry Resources

Get hundreds of popular Industry magazines, white papers, webinars, podcasts, and more; all available at no cost to you. With more than 600 complimentary offers, you'll find plenty of titles to suit your professional interests and needs. Click Here and Sign up today!

Java Training

Sponsored Links

Our Friends

Statistics

Locations of visitors to this page
visitor stats