- 浏览: 1380093 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (328)
- JSF (27)
- 生活 (12)
- Ajax (26)
- Maven (6)
- CSS (1)
- Shale (3)
- SiteMesh (1)
- Ext (15)
- JMX (2)
- Windows技巧 (7)
- 工作感悟 (18)
- SVN (2)
- SVG (0)
- GoogleGear (0)
- RAP (2)
- SOA与WebService (3)
- 笔记本技术研究 (1)
- Microsoft (2)
- 英语学习 (3)
- PHP (7)
- web 2.0 (6)
- 语义Web (1)
- IT史话 (3)
- iText (3)
- JVM (1)
- PropertiesEditor (1)
- J2SE (33)
- Spring (2)
- Java Batch (1)
- log (2)
- Struts2 (2)
- DWR (0)
- JAAS (3)
- EJB3 (4)
- Flex (8)
- JFreeChart (1)
- WAS (0)
- 数据库 (2)
- 摄影 (0)
- SQL (1)
- Google App Engine (1)
- linux (5)
- Eclipse plugin (10)
- Testing (0)
- Portal (0)
- 移动互联网 (0)
- SWTBot (1)
最新评论
-
江奇缘:
不错!!!!!!
web.xml里<filter-mapping>中的<dispatcher>作用 -
yy8093:
commonj 第三步,那个调用的方法要在哪里调?servle ...
JAVA中多种计时器的比较与分析 -
di1984HIT:
学习了,不错~
web.xml里<filter-mapping>中的<dispatcher>作用 -
penkee:
com.lowagie.text.DocumentExcept ...
iText中输出 中文 -
氵壞男亼乀:
我想请问下 你哪个html里面引入的几个js文件没看懂!你 ...
DWR入门教程之HelloWorld
Version 0.2 Copyright © 2007 Lars Vogel 16.10.2004 Abstract This article gives a introduction into the Java Preference API which is available since Java 1.4. The Java Preferences API provides a systematic way to handle user and system preference and configuration data, e.g. to save user settings, remember the last value of a field etc. Information saves with the Java Preference API is stored on the local machine of the user and is available to be re-used in the program, e.g. after a restart of the program. This Java Preferences API is not indented to save application data. The Java Preference API removes the burden from the individual programmer to write code to save configuration values on the different platforms his program may be running. Table of Contents The Preferences API provides a systematic way to handle program preference configurations, e.g. to save user settings, remember the last value of a field etc. Preferences are key / values pairs where the key is an arbitrary name for the preference. The value can be a boolean, string, int of another primitive type. Preferences are received and saved by get and put methods while the get methods also supply a default value in case the preferences is not yet set. java.util.prefs.Preferences can be easily used. You have to define a node in which the data is stored. Then you can call the getter and setter methods. The second value is the default value, e.g. if the preference value is not set yet, then this value will be used. Create the following program. Run the program twice. The value of "ID1" should be still true as we delete it. The value of "ID2" and "ID2" should have changed after the first call. Thank you for practicing with this tutorial. For questions and discussion around this article please use the www.vogella.de Google Group . Also if you note an error in this article please post the error and if possible the correction to the Group.
import java.util.prefs.Preferences;
public class PreferenceTest {
private Preferences prefs;
public void setPreference() {
// This will define a node in which the preferences can be stored
prefs = Preferences.userRoot().node(this.getClass().getName());
String ID1 = "Test1";
String ID2 = "Test2";
String ID3 = "Test3";
// First we will get the values
// Define a boolean value
System.out.println(prefs.getBoolean(ID1, true));
// Define a string with default "Hello World
System.out.println(prefs.get(ID2, "Hello World"));
// Define a integer with default 50
System.out.println(prefs.getInt(ID3, 50));
// Now set the values
prefs.putBoolean(ID1, false);
prefs.put(ID2, "Hello Europa");
prefs.putInt(ID3, 45);
// Delete the preference settings for the first value
prefs.remove(ID1);
}
public static void main(String[] args) {
PreferenceTest test = new PreferenceTest();
test.setPreference();
}
}
Tip
发表评论
-
百万级访问量网站的技术准备工作
2010-12-29 19:35 1426当今从纯网站技术上来说,因为开源模式的发展,现在建一个小 ... -
Java EE Productivity Report 2011
2010-12-21 17:02 1588What happens when over 1000 J ... -
An Introduction to LDAP
2010-04-13 16:24 1014An Introduction to LDAP Mich ... -
Java Interface 是常量存放的最佳地点吗?
2009-08-21 18:21 1206由于java interface中声明 ... -
Java的内存泄漏
2009-08-20 22:50 1264Java是如何管理内存 为了判断Java中是否有内 ... -
Transform XML into HTML using XSLT
2009-08-20 12:14 1783[howto.xml] <?xml versio ... -
eclipse 无法启动 JVM terminated. Exit code=-1
2009-08-09 13:52 2419eclipse 无法启动 JVM terminated. ... -
SDO ,WorkMananger,CommonJ overview
2009-07-06 10:51 1255Service Data Objects (SDO) -- P ... -
JAVA中多种计时器的比较与分析
2009-07-06 10:34 24038介绍 计时器可以提供运行基于时间的工作任务的功能,在计时器的管 ... -
Apache common io overview
2009-07-05 20:28 3835Apache 里面包含了太多有用的项目,值得我们仔细研究。恰当 ... -
Hashtable和HashMap的区别 Vector、ArrayList和List的异同(笔记)
2009-07-04 08:10 1855Hashtable和HashMap的区别:1.Hashtabl ... -
Java: System Properties
2009-05-25 11:10 2004From System Properties you ca ... -
SSL证书转换
2009-05-18 17:33 8457PKCS 全称是 Public-Key Cryptogra ... -
Keystores and Truststores
2009-05-18 14:39 2616Keystores and Truststores ... -
google app engine 是什么?
2009-04-08 18:50 3190Google是个真正能不断的 ... -
如何输入版权符号 copyright
2009-04-08 13:21 12173Unicode Character 'COPYRIGH ... -
深入浅出URL编码
2009-04-05 13:31 1085版权声明:如有转载请 ... -
Java IO一览
2009-04-04 12:23 1630对于我们常用的GBK中,英文是占用1个字节,中文是2个 对于 ... -
字节流与字符流的区别
2009-04-04 12:13 15050最近在项目中遇到一个encoding的问题,记录一下。 ... -
深入了解Unicode
2009-04-02 00:31 1648Unicode (统一码 、万国 ...
相关推荐
本文通过对数据压缩算法的简要介绍,然后以详细的示例演示了利用java.util.zip包实现数据的压缩与解压,并扩展到在网络传输方面如何应用java.util.zip包现数据压缩与解压
1. java.util.concurrent - Java 并发工具包 2. 阻塞队列 BlockingQueue 3. 数组阻塞队列 ArrayBlockingQueue 4. 延迟队列 DelayQueue 5. 链阻塞队列 LinkedBlockingQueue 6. 具有优先级的阻塞队列 ...
java.util.ConcurrentModificationException 异常问题详解1
详细介绍了java.util.logging.Logger的用法和结构,对如果扩展Logger起到抛砖引玉的作用!尊重劳动成果,亲下载了要给个评价!
Tomcat内存溢出的解决方法(java.util.concurrent.ExecutionException:java.lang.OutOfMemoryError),内附解决方案!
Exception in thread “main“ java.util.InputMismatchException
java.util.Date与java.sql.Date互转及字符串转换为日期时间格式.docx
java.util.concurrent系列文章(1) java.util.concurrent系列文章(1) java.util.concurrent系列文章(1) java.util.concurrent系列文章(1)
java并发工具包 java.util.concurrent中文版-带书签版
详细介绍java.util.Date和java.sql.Date相互转换的多种方法总结,希望对大家有帮助
这是我在编写struts2中遇到的问题,整理出来,包括截图,希望可以帮到大家
java.util包
世界范围内的时区列表。由 java.util.TimeZone 类导出
java.util包源码,pdf版,方便打印
使用java.util.timer实现的简单定时任务,在实现简单一次性定时任务时,使用java.util.timer非常的简单易用,适合没有接触过quartz的新手急用。
java.util.pdf
java.util.concurrent总体概览图。 收取资源分3分。需要的同学可以下载一下。 java.util.concurrent主要包括5个部分executor,colletions,locks,atomic,tools。 该图详细的列举了并发包下面的结构,包含所有接口和...
java.util包总结,方便大家学习。请多指教。
Java并发编程工具包java.util.concurrent的UML类结构图 PDF
Java.util包常用接口