Spring Framework fails on paths with Windows Drive Letters

736 views Asked by At

I am using Spring Framework version 4.3.18.RELEASE under Intellij on Windows 7. I am looking at the decompiled code of, for example, the class

org.springframework.core.io.DefaultResourceLoader

and the method

public Resource getResource(String location).

In that code it has a test for

location.startsWith("/")

This fails when the location is an absolute Windows path with a leading drive letter. E.g.

d:/git/thredds/dap4/d4tests/src/test/resources/

Is there a known alternate specification of such a path that will work?

2

There are 2 answers

0
Alpcan Yıldız On

Did you try with double slash and reverse slash? Like

C:\\Users\\...

or

C:\Users\...
0
Frederic Close On

try something like

 getResource("file:d:\\git\thredds\blah.txt") 

in case the file is stored along your classes

getResource("classpath:com/my/package/testing.txt");