1

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!

Pang
  • 9,564
  • 146
  • 81
  • 122
Drew
  • 58
  • 4
  • Can you post ls -l of /var so we can see the folders that Java can't... – Adam Mar 11 '15 at 17:27
  • Thanks, I figured it out. This code was running in a test on a VM but the test itself was still referencing all my local file paths. I changed it to a remote reference and it is working fine now. – Drew Mar 11 '15 at 17:53
  • BTW, you can post an answer to your own question. It's an accepted an encouraged practice. – DWright May 01 '15 at 01:37

0 Answers0