# 资源文件

> For the complete documentation index, see [llms.txt](https://www.jetbrains.com.cn/help/idea/llms.txt).

资源包括 [properties文件](properties-files.html)、图像、DTD和XML文件。 这些文件位于您的应用程序的  classpath 中，通常使用以下方法从classpath加载：

* `ResourceBundle.getBundle()` 适用于属性文件和资源包

* `getResourceAsStream()` 图标和其他文件

> **Tip:**
> 有关这些方法的更多信息，请参阅 [Location-Independent Access to Resources](https://docs.oracle.com/javase/8/docs/technotes/guides/lang/resources.html)。

在构建应用程序时，IntelliJ IDEA 会将所有资源复制到输出目录中，并保留相对于源路径的资源目录结构。 默认情况下，以下文件类型被识别为资源：

* `.dtd`

* `.jpeg`

* `.properties`

* `.gif`

* `.jpg`

* `.tld`

* `.html`

* `.png`

* `.xml`

可以在   编译器   对话框中配置识别资源文件的模式，格式为正则表达式(   设置   `Ctrl+Alt+S` (Windows), `⌘ Comma` (macOS), `⌘ Comma` (IntelliJ IDEA Classic (macOS)), `⌘ Comma` (macOS System Shortcuts), `Ctrl+Alt+S` (XWin), `Ctrl+Alt+S` (GNOME), `Ctrl+Alt+S` (KDE), `Ctrl+Alt+S` (Emacs), `Ctrl+Alt+S` (Sublime Text), `⌘ Comma` (Sublime Text (macOS)), `Ctrl+Alt+S` (Visual Studio), `⌘ Comma` (Visual Studio (macOS)), `Ctrl+Alt+S` (NetBeans), `Ctrl+Alt+S` (Eclipse), `⌘ Comma` (Eclipse (macOS))  `| 构建、执行、部署 | 编译器` )。 使用   资源模式  字段，您可以添加自己的文件扩展名并创建自定义资源列表。

有关如何将图片添加到您的项目的示例，请参阅 [示例：导入图像](view-images-in-ide.html#import-image-to-project)。

