6dd1b5393b34ed5cd5ff785e554ea5bc5630c9c5
[mediacube.git] /
1 package hu.user.mediacube.integration.safedelete;
2
3 import lombok.extern.log4j.Log4j2;
4
5 import java.nio.file.Files;
6 import java.nio.file.Path;
7 import java.nio.file.Paths;
8
9 @Log4j2
10 public class FileOperations {
11
12     static public void silentDelete(Path path) {
13         try {
14             Files.delete(path);
15         } catch (Exception e) {
16             log.catching(e);
17         }
18
19     }
20
21     static public void silentRename(Path source, String prefix) {
22         try {
23             String fileName = String.format("%s%s", prefix, source.getFileName().toString());
24             Path target = Paths.get(source.getParent().toAbsolutePath().toString(), fileName);
25             Files.move(source, target);
26         } catch (Exception e) {
27             log.catching(e);
28         }
29     }
30 }