Get the App
SLTechnology News&Howtos  ›  Development  › 

JDK 1.4How pitfalls 2 uses preferences and replaces properties settings

Shulou Source: shulou.com Published: 2022-06-02 11:13:57 09月26日 Update

This article will explain in detail how to use preference settings and replace properties settings in JDK 1.4.The content of this article is of high quality, so the editor will share it with you for reference. I hope you will have some understanding of the relevant knowledge after reading this article.

JDK 1.4 begins to provide preference settings that provide access to the registry under windows. But the user information is stored under the HKEY_CURRENT_USERSoftwareJavaSoftPrefs key and organized in a tree-like manner. Can be exported as a XML file. Do not know what to use under Linux to achieve registry functions, files? There was no experiment. [@ more@]

Package org.pitfalls.prefs

Import java.util.prefs.*

Public class PreferencesTest {

Private String mailServer

Private String timecardServer

Private String userName

Private String ftpServer

Public void storePreferences () {

Preferences prefs = Preferences.userRoot () .node (

"/ com/server")

Prefs.put ("mail", this.getMailServer ())

Prefs.put ("ftp", this.getFtpServer ())

}

/ * *

* @ param args

, /

Public static void main (String [] args) {

PreferencesTest test = new PreferencesTest ()

Test.setFtpServer ("orlux.org")

Test.setMailServer ("123456")

Test.storePreferences ()

}

Public String getFtpServer () {

Return ftpServer

}

Public void setFtpServer (String ftpServer) {

This.ftpServer = ftpServer

}

Public String getMailServer () {

Return mailServer

}

Public void setMailServer (String mailServer) {

This.mailServer = mailServer

}

Public String getTimecardServer () {

Return timecardServer

}

Public void setTimecardServer (String timecardServer) {

This.timecardServer = timecardServer

}

Public String getUserName () {

Return userName

}

Public void setUserName (String userName) {

This.userName = userName

}

}

So much for sharing about JDK 1.4 pitfalls 2 how to use preferences and replace properties settings. I hope the above can help you and learn more. If you think the article is good, you can share it for more people to see.

Tags: Preferences content functions files articles more registry knowledge articles good information methods users quality reference help related experiments Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL OPPO Reno Redmi Apple Linux