-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathFileService.java
More file actions
36 lines (28 loc) · 1.03 KB
/
FileService.java
File metadata and controls
36 lines (28 loc) · 1.03 KB
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
29
30
31
32
33
34
35
36
package de.telran.service;
import de.telran.entity.ActionableImage;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
public class FileService {
public List<String> loadStringsFromFile(String fileName) {
try {
return Files.lines(Paths.get(fileName)).collect(Collectors.toList());
} catch (Exception ex) {
System.err.println(ex.getMessage());
return Collections.EMPTY_LIST;
}
}
public void saveImageAsFile(ActionableImage image) {
try {
ImageIO.write(image.getImage(), "jpg",new File("/Users/slukichev/Downloads/images/img_"+image.hashCode()+".jpg"));
} catch (Exception ex) {
ex.printStackTrace();
}
}
//https://s3-eu-west-1.amazonaws.com/lukaroundimg/beelitz2017/1a.jpg -> s3-eu-west-1.amazonaws.com.lukaroundimg.beelitz2017.1a.jpg
}