本文介绍了如何在 IntelliJ 中将资源文件添加到 JAR的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用 IntelliJ IDEA 14,我想将 src 之外的文件添加到 JAR 文件中.这是我目前的项目结构.
I am using IntelliJ IDEA 14 and I want to add file outside of src to the JAR file. This is my current project structure.
我想将 layout.txt 和 saveddata.txt 添加到 JAR 文件可执行文件中.我已经在谷歌上搜索了一段时间找不到解决方案
I want to add layout.txt and saveddata.txt to the JAR file executable. I've been googling on that for a while can't find the solution
如果您需要查看我的代码.这就是我读取文件的方式
In case you need to see my code. This is how I am reading file
private Path layoutPath = Paths.get("resources/layout.txt");
content = new String(Files.readAllBytes(layoutPath));
这是我的项目结构
推荐答案
- 在与src"相同级别创建一个名为resources"的文件夹
- 右键单击文件夹,选择将目录标记为 -> 资源根目录"
这篇关于如何在 IntelliJ 中将资源文件添加到 JAR的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!