-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathDownloadService.java
More file actions
28 lines (25 loc) · 958 Bytes
/
DownloadService.java
File metadata and controls
28 lines (25 loc) · 958 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package de.telran.service;
import de.telran.entity.ActionableImage;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
public class DownloadService {
public List<ActionableImage> downloadImages(List<ActionableImage> images) {
List<ActionableImage> imageList = new ArrayList<>(images);
for(ActionableImage actionableImage:images) {
try {
URL url = new URL(actionableImage.getSourceUrl());
BufferedImage image = ImageIO.read(url);
actionableImage.setImage(image);
actionableImage.setSuccessfull(true);
} catch (Exception ex) {
System.err.println(actionableImage.getSourceUrl());
System.err.println(ex.getMessage());
actionableImage.setSuccessfull(false);
}
}
return imageList;
}
}