你可以在.jar中存储数据吗?

问题描述:

我正在学习java,目前正在尝试开发一个简单的应用程序。我的问题是你可以在.jar内部的文本文件中存储有关设置等的数据吗?如果是这样,您将如何在java中访问它?很抱歉,如果这是一个非常愚蠢的想法。

I'm learning java and am currently trying to develop a simple application. My question is can you store data about settings, etc in a text file internal to a .jar? If so how would you go about accessing this within java? Sorry if this is a really stupid idea.

InputStream is = this.getClass().getResourceAsStream("/data/file.txt");

您获得的资源需要在类路径上

The resources you are getting need to be on the classpath