我正在建立一个餐厅系统,我想授予管理员更改和保存设置的权限,以便当其他用户登录时可以找到新设置。
Java has a dedicated preferences API , which is more powerful than using Properties files - that should be exactly what you want. It offers "System" preferences and "User" preferences - presumably the admin would be allowed to change "System" preferences.
You can use the java properties api to save any settings as Key-Value pairs.
A tutorial is here http://java.sun.com/docs/books/tutorial/essential/environment/properties.html
This can save your properties as .properties files as well as XML files
You can create a directory to the disk and store files which are looking like
user=Ben
font=arial
...
These file you can read with a java.util.Properties object.
Properties p;
p.load(inStream);
The properties you can add to the system properties and use it in every location of your code by calling
System.setProperty(font, arial);
System.getProperty(font);
有很多方法可以做到:-序列化-首选项API-使用文本文件(XML,属性文件,ini文件等)-数据库
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.