How to read a file inside a jar's resources from ouside the jar

后端 未结 1 409
南旧
南旧 2021-01-25 17:25

I have a file X.json inside abc.jar in its classpath. There is a method readFile in abc.jar which reads the file as

URL url = Abc.class.getClassLoader().getResou         


        
相关标签:
1条回答
  • 2021-01-25 17:42

    By the time of deployment, those resources will become an embedded-resource. That being the case, the resource must be accessed by URL instead of File. See the info page for the tag, for a way to form an URL.

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