How to package resources in Jar properly

后端 未结 1 810
野的像风
野的像风 2020-11-29 13:20

I know that there are other questions out there targeting the same issue but the thing is that the solutions don\'t work for me. I have a little tool that is supposed to re

1条回答
  •  北海茫月
    2020-11-29 13:52

    Mark the resource folder under your project's root folder as a "Source Folder" in Eclipse (right click on the folder, go to "Build Path" > "Use as source folder"). Then read the resources like this:

    InputStream is = MyClass.class.getClassLoader().getResourceAsStream(name + ".SOURCE");
    BufferedReader reader = new BufferedReader(new InputStreamReader(is));
    String line = reader.readLine();
    

    0 讨论(0)
提交回复
热议问题