new const to specify classPathResource

This commit is contained in:
Theophyl Hoguet committed 2023-03-13 23:28:03 +01:00
1 parent 3d076e21d3
commit 754919b518
1 file changed
+5 -6
@@ -18,16 +18,15 @@ public class ImageDao implements Dao<Image> {
private final Map<Long, Image> images = new HashMap<>();
public ImageDao() {
try {
final var folderPath = new ClassPathResource("images");
public ImageDao() throws IOException {
this(new ClassPathResource("images"));
}
public ImageDao(ClassPathResource folderPath) throws IOException {
if (!folderPath.exists())
throw new ImageResourceMissingException("folder images doesn't not exsit");
final var folder = folderPath.getFile();
getAllImages(folder);
} catch (final Exception e) {
e.printStackTrace();
}
}
public void getAllImages(final File folder) {