用Java做设置文件的最简单方法是什么?

用Java做设置文件的最简单方法是什么?

问题描述:

显然,我想避免对应用程序中的路径等进行硬编码,因此,我想制作一个设置文件来存储诸如字符串之类的简单内容.这样做最简单的方法是什么?我在思考可可如何使用对象持久性的思路,但似乎找不到任何等效的方法.

Obviously enough, I want to avoid hardcoding paths and such into my application, and as a result, I'd like to make a settings file that will store simple things like strings and such. What is the simplest way to do so? I was thinking something along the lines of how Cocoa uses object persistence, but I can't seem to find anything equivalent.

您可以使用属性文件> java.util.Properties 类.

You could use properties files which are manipulated with the java.util.Properties class.