Java Notes-12(Preferences API, The Logging API)
来源:互联网 发布:淘宝化妆品上新技巧 编辑:程序博客网 时间:2024/06/05 01:18
Summary:Preferences API, The Logging API
- The Preferences API is like a portable version of the Windows registry, a mini-database in which you can keep small amounts of information, accessible to all applications
-Preferences are stored logically in a tree.
Preferences prefs = Preferences.userRoot().node("oreilly/learningjava");prefs.put("author", "Niemeyer");prefs.putInt("edition", 4);String author = prefs.get("author", "unknown");int edition = prefs.getInt("edition", -1);
-Preferences are stored in two separate trees: system preferences and user preferences.System preferences are shared by all users of the Java installation. But user preferences
are maintained separately for each user;
-The node() method accepts either a relative or an absolute path.
Preferences prefs =Preferences.userRoot().node("oreilly").node("learningjava");
-Often your application should be notified if changes are made to the preferences while it’s running. You can get updates on preference changes using the PreferenceChange
Listener and NodeChangeListener interfaces.
Preferences prefs =Preferences.userRoot().node("/oreilly/learningjava");prefs.addPreferenceChangeListener( new PreferenceChangeListener() {public void preferenceChange(PreferenceChangeEvent e) {System.out.println("Value: " + e.getKey()+ " changed to "+ e.getNewValue() );}} );
-The java.util.logging package provides a highly flexible and easy-to-use logging framework for system information, error messages, and fine-grained tracing (debugging) output.
-The heart of the logging framework is the logger, an instance of java.util.logging.Logger .
package com.oreilly.learnjava;public class Book {static Logger log = Logger.getLogger("com.oreilly.learnjava.Book");
log.warning("Disk 90% full.");log.info("New user joined chat room.");
-a logger for the name “global” is provided in the static field Logger.global . You can use it as an alternative to the old standby System.out.println()
Logger.global.info("Doing foo...")
-Before a logger hands off a message to its handlers or its parent’s handlers, it first checks whether the logging level is sufficient to proceed. If the message doesn’t meet the required level, it is discarded at the source.
0 0
- Java Notes-12(Preferences API, The Logging API)
- Java Notes-12(Preferences API, The Logging API)
- The Logging API
- java Logging API 使用
- Java Logging API
- Java Logging API
- Java Logging API - Tutorial
- Java API Study Notes
- Java Reflection API Notes
- An Introduction to the Java Logging API (part)
- JAVA Logging API 学习笔记
- logging API
- Best practices for the logging REST API
- Java logging API之配置方法
- Java logging API之配置方法
- 用 Preferences API 存储对象
- 用 Preferences API 存储对象
- 用 Preferences API 存储对象
- oracle 执行计划修改学习---query block
- 【Android开发】图形图像处理技术-旋转、缩放、倾斜和平移图像
- Android实现圆角边框
- 辛星整理git中的tag
- Java知识整理——JDBC
- Java Notes-12(Preferences API, The Logging API)
- 【android学习笔记】关于相对布局RelativeLayout的各种属性介绍
- 华硕笔记本的U盘启动
- java.util.concurrent.Queue 并发队列
- 如何在windows上建立TimesTen内存数据库
- 单例模式(JAVA)
- centos修改源
- 在原来的基础上翻转数组
- 欢迎使用CSDN-markdown编辑器