Need help with strange Class#getResource() issue

前端 未结 4 1794
太阳男子
太阳男子 2021-01-20 01:26

I have some legacy code that reads a configuration file from an existing jar, like:

URL url = SomeClass.class.getResource(\"/configuration.properties\");
//          


        
4条回答
  •  攒了一身酷
    2021-01-20 02:13

    It works with getresourceasstream because it is in the classpath, but it doesn't work with the URL maybe because the URL is not ok.

    I don't know if the URL that getResource is creating is not ok, or there isn't a correct handler for the protocol (wouldn't it be file:jar:c:/myjar.jar!configuration.properties or something by the like (with two colons?)

提交回复
热议问题