Drew
Drew

Reputation: 58

Java can see some folders/files but returns NoSuchFileException on others

I was getting a NoSuchFileException when I was trying to access a file so I went through the usual process, checked the file existed, etc. I did this by checking the exception:

java.nio.file.NoSuchFileException: /var/config/file/test111.txt

then

vim /var/config/file/test111.txt

to verify the file actually existed. After some further testing I realized java couldn't see the /config folder.

File f = new File("/var");
f.list();

This returned some of the files and folders in /var, but not others, including /var/config. I did a ls -lah on the folder to check permissions and as far as I can tell there is no difference between what java can and can't see. For example it can see /var/cache

drwxr-xr-x  6 root  root   4096 Feb 24 09:03 cache
drwxr-xr-x  3 root  root   4096 Feb 24 09:04 config

Why would java be able to see some folders but not others when permissions are the same between folders?

Thanks!

Upvotes: 1

Views: 206

Answers (0)

Related Questions