I am attempting to grab all of the mkv files in a folder and place their names in an array, yet my code only returns one value for some reason. I thought the FilenameFilter() would return all appropriate values, not just the first entry it encounters.
//Get a list of all mkv files in the extraction folder
File file = new File(extractedFolder);
File[] listoffiles = file.listFiles(new FilenameFilter() {
public boolean accept(File file, String name) {
return name.toLowerCase().endsWith(".mkv");
}
});
Do I need to iterate through this code? Is my array only setup to handle one entry? Those are the only two potential problems I can see with this code, but both seem fine to my eye.
Java: Find .txt files in specified folder is a resource I was using as well.
EDIT: My filestructure has everything sitting in the same folder. That folder address is
C:\Users\user1\Documents\folder1\extraction files.
Inside the "extraction files" folder, are 27 mkv files and 28 xml files (see image). The code I gave above only is pulling 12 files at a time. Do I need to specify a number when I initially create the array?
EDIT 2 Using this resource (Java process - unable to unzip zip file), I realized that a buffer I was using to unzip files (before grabbing them with the code above) was filling up and killing the process. Essentially, the issue was using a Runtime() instead of a ProcessBuilder() (which can prevent cmd from buffer overflows). Problem solved!