Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

JDK 1.4How pitfalls 2 uses preferences and replaces properties settings

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report