+ 7
the variable filename2 is only assigned to the last file in the directory.I want to loop through each file in the directory.
// get Names of image files in the knowledge base': String absolutePath = "C:/Write"; File dir = new File(absolutePath); File[] filesInDir = dir.listFiles(); for(File file:filesInDir) { ImageIO.read(file); filename2 = file.getPath(); } int ret; ret = compareFeature(filename1, filename2); if (ret > 0) { System.out.println(" Image Match found."); } else { ImageIO.write((RenderedImage) image, "jpg", new File("C:/Write/"+ filename)); System.out.println(" Image Match not found."); }
1 Odpowiedź
+ 5
for(File file: filesInDir){
filename2 = file.getPath();
}
--> filename2 = first file, filename2 = second file, ... filename2 = last file --> end loop
If you want all files you can use a list or an array.