The idea is for non-directory files in a folder by traversing the file size statistics, and the same directory where the file traversal operation, as follows:
package word; import java.io.File; import java.io.FileNotFoundException; public class Aa { static iong Numb = 0; // total size public static void main (String [] args) throws a FileNotFoundException { // A method of automatically generating stubs TODO Path String = "C: \\ File"; // to traverse the path File file = new new File (path); // get its file objects fil (file); System.out.println(numb); } public static void fil(File a) throws FileNotFoundException { String path =a.getPath(); File File = new new File (path); // get its file object File [] FS = File.listFiles (); // traverse the files and directories under the path, on the File array for (File F: FS) { / / traverse file [] array IF (! f.isDirectory ()) // if not directory (ie files), be traversed { Numb + = f.length (); // Get File Size} the else {FIL (F); } } } }