Need help with strange Class#getResource() issue

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

    use urlConnection.setUseCaches(false), since it's an ant task, it's likely not to be forked in a separate process. The URLs cache the files (or the JarFile in that case)... if the files is change due to the build, you get quite a similar behavior.

    you may want to close the modified jar files meanwhile useCaches(true), JarURLConnection.getJarFile().close()

    Sometime I wish handling of Jar/Zip was a little better

    cheers

提交回复
热议问题