Jar package how to read resource files within the package

purpose

Jar read in the resource file

principle

Class loader encapsulated to obtain resources (the Jar as a whole, can not be used to locate the URI package file)

algorithm

  1. Get the class loader
  2. Obtain specific resource file input stream

Algorithms practice

类名.class.getClassLoader().getResourceAsStream("资源文件在包内的相对位置");
Published 118 original articles · won praise 14 · views 50000 +

Guess you like

Origin blog.csdn.net/github_38641765/article/details/100051259