I need to upload a Folder with sum x of .png files and save them into a hashmap. How can I achieve this. My thought was
HashMap<Integer,Image> map = new HashMap<>();
for (int i= map.size();map>0;map-- ){
map.put(i, new Image(new FileInputStream("C:\\Users\\drg\\Documents\\image"+i+".png")));
}
the problem is, in the beginning my HashMap contains 0 items, therefor it will always remain 0. So how can I add the .png files to my HashMap if I dont know how many .png files are in my folder.
Another problem is that I am using the FileInputStream and need to know the exact "name" of the .png file. How can I find out how many .png files there are and upload them into my HashMap without needing to know their exact filename?