Adv Java Program : Write a Java program to display given extension files from a specific directory on server machine.
Slip14AB.java
import java.io.File;
import java.io.FilenameFilter;
public class Slip14AB{
public static void main(String a[]){
File file = new File("C:/Users/Mayur/Desktop/T.Y.B.B.A(CA)");
String[] list = file.list(new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
if(name.toLowerCase().endsWith(".java")){
return true;
} else {
return false;
}
}
});
for(String f:list){
System.out.println(f);
}
}
}
run :
javac Slip14AB.java
javac Slip14AB
0 Comments