new const to specify classPathResource
This commit is contained in:
1 parent
3d076e21d3
commit
754919b518
1 file changed
+9
-10
@@ -18,16 +18,15 @@ public class ImageDao implements Dao<Image> {
|
|||||||
|
|
||||||
private final Map<Long, Image> images = new HashMap<>();
|
private final Map<Long, Image> images = new HashMap<>();
|
||||||
|
|
||||||
public ImageDao() {
|
public ImageDao() throws IOException {
|
||||||
try {
|
this(new ClassPathResource("images"));
|
||||||
final var folderPath = new ClassPathResource("images");
|
}
|
||||||
if (!folderPath.exists())
|
|
||||||
throw new ImageResourceMissingException("folder images doesn't not exsit");
|
public ImageDao(ClassPathResource folderPath) throws IOException {
|
||||||
final var folder = folderPath.getFile();
|
if (!folderPath.exists())
|
||||||
getAllImages(folder);
|
throw new ImageResourceMissingException("folder images doesn't not exsit");
|
||||||
} catch (final Exception e) {
|
final var folder = folderPath.getFile();
|
||||||
e.printStackTrace();
|
getAllImages(folder);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getAllImages(final File folder) {
|
public void getAllImages(final File folder) {
|
||||||
|
|||||||
Reference in new issue
Block a user