Warm tip: This article is reproduced from serverfault.com, please click

I'm trying to read file in java it works if i just created the file but after while it will not work

发布于 2020-12-02 08:10:33

im facing little weird proplem

i have a service that read file from local server i used java.nio.file for that

it works perfectly if the file just created or uploaded to the folder, if the file is old it will give me this error

java.io.FileNotFoundException: File '/mnt/A/B/123.png' does not exist

and to let the old files work again i need to ssh the server and open the directory and list files

after i do that it return working for a while then it stops again and gives the same above error

the server that I'm using is Apache Tomcat/9.0.36 this is my code

return Files.readAllBytes(getPath(resourceLoader, uploadDir + "/" + directory + "/" + fileName));

i tried to use org.apache.commons.io.FileUtils but no luck I'm getting the same issue

return org.apache.commons.io.FileUtils.readFileToByteArray(getPath(resourceLoader, uploadDir + "/" + directory + "/" + fileName).toFile());
Questioner
MLK
Viewed
0
MLK 2020-12-06 14:28:32

the issue was fixed by restarting the server that is mounting the files