Need help with strange Class#getResource() issue

前端 未结 4 1831
太阳男子
太阳男子 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:01

    There are bugs in several Java versions when using file URLs containing spaces. "/path/to/jar" is probably not your real path, so I at least assume that this is what you're running into. Your code is at least in theory ok.

提交回复
热议问题