为什么资源path通过Java代码在Windows中变为空?

我正在写文件的path

if (!new File(path).exists()) { URL location = this.getClass().getClassLoader().getResource(path); if (location == null) { location = Thread.currentThread().getContextClassLoader().getResource(path); } path = location.getPath(); path = URLDecoder.decode(path, "utf-8"); path = new File(path).getPath(); if (!new File(path).exists()) { throw new Exception("Unable to resolve path: " + path); } } 

相同的代码工作的Linux机器,但对于Windows我得到的location = Nullpath=./../config/equipmenttemplates/已经在那里。

Solutions Collecting From Web of "为什么资源path通过Java代码在Windows中变为空?"