This can be done with the help of FileUtils.sizeofDirectory(File Name) method of FileUtils class. This gives size in bytes.
import java.io.File; import org.apache.commons.io.FileUtils; public class GetDirSize { public static void main(String[] args) { long size = FileUtils.sizeOfDirectory (new File("C:/Windows/Fonts")); System.out.println("Size: " + size + " bytes"); } }
No comments:
Post a Comment