IntelliJ Idea Read resource fileCategory: "Java Basics"2015-02-12 16:45 780 people read reviews (0) favorite reports
Directory (?) [+]
Original address
http://yanwushu.sinaapp.com/intellij-idea_raed_resource_file/
Official documents
The following is an explanation of the resource file of idea in the Jetbrain website, which has a link to this article at the end.
The resource files here include properties files, pictures, DTD files, XML files. These files are placed under the Classpath path of the project. You can usually get them by using the following methods:
Resourcebundle.getbundle ()//Get Properties file or resource bundle (resource bundles)
Loadresourceasstream ()//Get icon or other files
Build application, Idea copies these resource files to the application's output directory and maintains the directory structure of those resources. Idea the default resource file name extension is:
Properties/xml/html/dtd/tld/gif/png/jpeg/jpg
You can implement the extension of the custom resource file by configuring the idea default resource file extension in the Complile dialog box, in the form of regular expressions.
Instance
Create a PROJEC 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 generic directory named res
2. Project Properties dialog box, select Res directory, click the Res button, such as:
The key code is:
URL url = TestFrame.class.getResource ("/white.jpg");
ImageIcon icon = newimageicon (URL);
The operation results are as follows
Resources
Https://www.jetbrains.com/idea/help/resource-files.html
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
IntelliJ Idea Read Resource file