The following java program get the list of all html file from the directory folder
import java.io.File;
import java.io.FileFilter;
class GetHtmlFilesList {
FileFilter htmFileFilter = new FileFilter() {
@Override
public boolean accept(File file) {
if (file.getName().endsWith(".htm")) return true;
else return false;
}
};
public File[] getListOfHtmFiles(String dataPath) {
File dataFolder = new File(dataPath);
return dataFolder.listFiles(htmFileFilter);
}
public static void main(String arg[]) {
String DATA_PATH="/home/brij/mathmuni2/docs/2017-11-30_updated/htm_and_images";
GetHtmlFilesList getHtmlFileList=new GetHtmlFilesList();
File[] fileList=getHtmlFileList.getListOfHtmFiles(DATA_PATH);
for (File f : fileList) {
System.out.println("File Name = "+f.getName());
}
}
}
No comments:
Post a Comment