我有一個路徑化子性質的文件到文件我的罐子裏加載文件給出了錯誤的道路
logo.cgp=images/cgp-logo.jpg
這個文件已經存在:
我想加載這個文件在我的項目,所以我這樣做:
String property = p.getProperty("logo.cgp"); //This returns "images/cgp-logo.jpg"
File file = new File(getClass().getClassLoader().getResource(property).getFile());
但後來當我做file.exists()
我得到false
。當我檢查file.getAbsolutePath()
它導致C:\\images\\cgp-logo.jpg
我在做什麼錯?