original address
official documentation
The following is the explanation of the resource files in the idea on the jetbrain official website. There is a link to this article at the end of the article.
The resource files here include properties files, pictures, dtd files, and xml files. These files are placed on the project's classpath. They can usually be obtained using the following methods:
ResourceBundle.getBundle() //Get properties file or resource bundles
loadResourceAsStream() //Get icon or other files
When building the application, idea will copy these resource files to the output directory of the application and maintain the directory structure of these resources. Idea's default resource file extensions are:
properties/xml/html/dtd/tld/gif/png/jpeg/jpg
You can configure the default resource file extension of idea in the form of regular expression in the complile dialog, and then implement the extension of the custom resource file.
Example
Create a project with the following structure:
As you can see, res is a resource directory, and the way to create a resource file directory is
1. Create a new normal directory named res
2. Project Properties dialog box -> select the res directory, click the res button, as shown below:
The key code is:
URL url = TestFrame.class.getResource("/white.jpg");
ImageIcon icon = newImageIcon(url);
The running result is as follows
resource
https://www.jetbrains.com/idea/help/resource-files.html