I tried many ways to find the file type I wanted, and here are my results when done.
public static void main( String args[]){
final String dir2 = System.getProperty("user.name"); \\get user name
String path = "C:\\Users\\" + dir2;
digFile(new File(path)); \\ path is file start to dig
for (int i = 0; i < StringFile.size(); i++) {
System.out.println(StringFile.get(i));
}
}
private void digFile(File dir) {
FilenameFilter filter = new FilenameFilter() {
public boolean accept(File dir, String name) {
return name.endsWith(".mp4");
}
};
String[] children = dir.list(filter);
if (children == null) {
return;
} else {
for (int i = 0; i < children.length; i++) {
StringFile.add(dir+"\\"+children[i]);
}
}
File[] directories;
directories = dir.listFiles(new FileFilter() {
@Override
public boolean accept(File file) {
return file.isDirectory();
}
public boolean accept(File dir, String name) {
return !name.endsWith(".mp4");
}
});
if(directories!=null)
{
for (File directory : directories) {
digFile(directory);
}
}
}