Java properties and synchronize/unmodifiable collections

Properties Class: 
Is a persistent Hashtable that store key-value pairs of Strings.
Properties are intended to use for user accessable file of application preferences.
EX of P:
private Properties table;
table = new properties();
table.setProperty("color","red");
table.setProperty("size","200");

Some useful method:
FileOutputStream output = new FileOutputStream("props.dat");
table.store(output,"sample properties");

FileInputStream input = new FileInputStream("props.dat");
table.load(input);

table.getProperty(Strint(key));
table.clear();

Synchronized Collections:
EX:
List list1 = new ArrayList();
List list2 = Collections.synchronizedList(list1); //static method provide a wrapper synchornized object

Unmodifiable collecitons:
EX:
List list1 = new ArrayList();
List list2 = Collections.unmodifiableList(list1);
//unmodifiable wrapper to create a collection taht offers read-only access to others

中文注: Collection API 另外还包含一些abstract Classes 让我们用来extends, 省去了要自己写很多新methods 并且要implements 很多对应的collection Interface 的Methods 的麻烦。

评论

此博客中的热门博文

Nu förbjuder Kina handel med elfenben

Fader av pingyins

Kineserna vill köpa Volvos kompetens