0

I have a project in eclipse where all my source code is under mbl/src. I am exporting this code as a runnable jar. I have got another folder under mbl/files which contains some of the properties files.I want to export these files also but eclipse doesnt give any such option. I have put the mbl/files under add class folder in build path options but still I am facing similar issues. I have also put the files folder directly under src folder but still it is not able to access it.I am using following options in commandline.

java -jar myprogram.jar arg1

It gives this error:

Unable to find files/text1.properties

text1.properties is under mbl/files/text1.properties

and is referred in the following manner from main class:

FileInputStream fs=new FileInputStream("files\\text1.properties");
4

1 回答 1

0

Jars 中的资源,需要通过该Class.getResource(...)方法读取。

此方法返回一个URL对象,您可以从中获取一个InputStream

于 2012-07-26T19:33:16.843 回答