close #10
This commit is contained in:
1 parent
93cbf58ba6
commit
bd5f2d7010
5 files changed
+8
-15
No files matched your search
@@ -25,33 +25,26 @@ public class ImageDao implements Dao<Image> {
|
|||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
System.out.println("IMAGEEEEEEEEEEEEEEs");
|
|
||||||
for (Image img : retrieveAll()) {
|
|
||||||
System.out.println(img.getName());
|
|
||||||
}
|
|
||||||
System.out.println("ENNNNNNNNNNNNNNd");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getAllImages(final File folder) {
|
public void getAllImages(final File folder) {
|
||||||
for (final File fileEntry : folder.listFiles()) {
|
for (final File file : folder.listFiles()) {
|
||||||
if (fileEntry.isDirectory()) {
|
if (file.isDirectory()) {
|
||||||
getAllImages(fileEntry);
|
getAllImages(file);
|
||||||
} else {
|
} else {
|
||||||
final ClassPathResource imgFile = new ClassPathResource(fileEntry.getName());
|
|
||||||
String extension = "";
|
String extension = "";
|
||||||
|
|
||||||
int i = fileEntry.getName().lastIndexOf('.');
|
int i = file.getName().lastIndexOf('.');
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
extension = fileEntry.getName().substring(i + 1);
|
extension = file.getName().substring(i + 1);
|
||||||
}
|
}
|
||||||
if (!extension.equals("jpg") && !extension.equals("pgn")) {
|
if (!extension.equals("jpg") && !extension.equals("png")) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
byte[] fileContent;
|
byte[] fileContent;
|
||||||
try {
|
try {
|
||||||
fileContent = Files.readAllBytes(imgFile.getFile().toPath());
|
fileContent = Files.readAllBytes(file.toPath());
|
||||||
Image img = new Image(imgFile.getFilename(), fileContent);
|
Image img = new Image(file.getName(), fileContent);
|
||||||
images.put(img.getId(), img);
|
images.put(img.getId(), img);
|
||||||
} catch (final IOException e) {
|
} catch (final IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 14 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 203 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 314 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 38 KiB |
Reference in new issue
Block a user