The following example demonstrates using FileUtils.sizeofDirectory(File Name) of the File class to obtain the size of the directory:
/* author by w3cschool.cc Main.java */import java.io.File;import org.apache.commons.io.FileUtils;public class Main { public static void main(String[] args) { long size = FileUtils.sizeOfDirectory (new File("C:/test")); System.out.println("Size: " + size + " bytes"); }
The output result of running the above code is:
Size: 2048 bytes
The above is the Java example - Get the content of the directory size. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!