IntelliJ Idea Read Resource file

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.