import java.io.*; import java.util.*; // Count the number of files in a directory and all of its subdirectories recursively public class DirectorySize { public static void main(String[] args) { System.out.print("Enter directory name: "); Scanner input=new Scanner(System.in); String dir=input.nextLine(); System.out.println(getSize(new File(dir)) + " files"); // dir is the String of the directory name, use new File(dir) to open this location and pass this File to getSize } public static int getSize(File f) { int size=0; if(f.isDirectory()){ // if f is a directory, collect all of its files and subdirectories and do this method recursively File[] files=f.listFiles(); for(int i=0;files!=null&&i