i am copying a file like this:
File copy = new File(file.getName());
// path relative to current working directory
Path relativePath = Paths.get("src/main/resources/images/", copy.getPath());
java.nio.file.Files.copy(
file.toPath(), // input path
relativePath, // target path
java.nio.file.StandardCopyOption.REPLACE_EXISTING);
logger.info("Copy file to path {}", relativePath);
// save path for NPC
currentImagePath = "/images/"+copy.getPath();
and then save the path to the database. When I try to open the copied file like this:
Image image = new Image(bild);
(bild is the currentImagePath from before), I get an Exception saying that it was an invalid URL or the resource was not found. However, if I end the program and start it anew, opening the file works without a problem. Is there a solution to this?