Imagine that you have directory called test1 in C drive containing some files,within which there is a directory called test2 (sub-directory of test1) containing some other set of files. Considering this, what statements are true about the following program?
package io;
import java.io.File;
import java.io.FileFilter;
public class DirLister {
public static void main(
String[] args) {
String path = "C:\\test1";
list(path);
}
static void list(String path){
File fileObject = new File(path);
if (fileObject.exists()){
if (fileObject.isDirectory()){
System.out.println("Dir-->" + fileObject.getAbsolutePath());
File allFiles[] = fileObject.listFiles(new MyFileLister());
for (File aFile : allFiles){
list(aFile.getAbsolutePath());
}
}else{
System.out.println("File-->" + fileObject.getAbsolutePath());
}
}
}
}
class MyFileLister implements FileFilter{
@Override
public boolean accept(File pathname) {
return pathname.getAbsolutePath().endsWith(".bmp");
}
}
1. The program will list down all the files within the directory test1 and test2
2. The program will list down only the files in directory test1
3. The program will list down only the files in directory test2
4. The program will run infinitely.