[solution] the resource file cannot be found in the jar package of Java

The file is placed in the Resources folder and will appear in the boot after it is typed as a jar package_ INF/classes/ xx.xx The second one is the second one;

The file path uses “absolute path”/ xx.xx “, load URL and create InputStream with classloader:

URL fileURL=this.getClass().getResource("/xx.xx");
InputStream is=this.getClass().getResourceAsStream("/resource/res.txt");

Read More: