基本思路
A resource contained within a JAR file is not itself a file, and cannot be read using a FileInputStream. If you have code that absolutely requires a FileInputStream, then you'll need to extract the data using getResourceAsStream(), copy it into a temporary file, then pass a FileInputStream for that temporary file to your code.
-- <cite>StackOverFlow</cite>
翻譯:
由于包含在Jar包中的資源文件本身不是一個文件绒极,所以FileInputStream不能夠直接讀取Jar中文件的內(nèi)容紧索,而如果沒有其他選擇必須使用FileInputStream(比如你使用的第三方庫就是使用FileInputStream纤壁,需要你傳遞文件路徑)的情況下穷当,你可以考慮通過getResourceAsStream()先獲取文件流辰企,然后創(chuàng)建一個系統(tǒng)臨時文件宠能,把臨時文件傳遞給FileInputStream使用夸楣。