0

So, on my FS (Linux box, just in case), I have directories that actually match full windows paths (Can't change that, part of the requirement):

$ ls -l some-local-dir/
total 8
drwxrwxr-x 2 spiderman spiderman 4096 jun 21 08:30 'C:\desktop\some-dir'

So, some-local-dir, that's a normal plain directory on my linux box... and, as you can see, it's showing a unique directory inside which has a name consisting of a full windows path. No problem on bash. I'm able to play around with it without any issues (copying, putting stuff inside, etc).

On Java, I'm able to see the file and the content by using File, replace the \s with \\s and it works. But when I try to use Resources.getResource using the same trick, it doesn't work:

java.lang.IllegalArgumentException: resource path-inside-resources not found

I've tried replacing \ for \\ on the strings.... even \\\\ (just in case) but it still can't seem to handle the directory name.

Interestingly enough, if I take a look on IntelliJ, I can see the up to some-local-dir in resources, but nothing is shown inside (I would expect to see the specially-named directory inside)

WORKAROUND As a temporary workaround, for testing, I will be skipping using Resources altogether and will resort to use Files.readAllBytes(Paths.get(crazy-path)) which works fine if I also prefix the path to get to resources dir from the root of the project). Would like to work with Resources and not have to use this workaround, though.

eftshift0
  • 26,375
  • 3
  • 36
  • 60

0 Answers0