SIMPLE JAVA PROGRAM TO FIND OUT NUMBER OF FOLDERS IN DIRECTORY
CODE :
import java.io.File;
public class NumberOfFileInFolder {
public static void main(String[] args) {
File f1 = new File("D:/SONGS");
int count1 = 0;
for (File file : f1.listFiles()) {
if (file.isDirectory()) {
count1++;
}
}
System.out.println("Number of directories: " + count1); // Show number of directory only
}
}
No comments:
Post a Comment