<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
	<channel>
		<title><![CDATA[Latest posts for the topic "如何將Properties排序輸出?"]]></title>
		<link>https://forum.andowson.com/posts/list/5.page</link>
		<description><![CDATA[Latest messages posted in the topic "如何將Properties排序輸出?"]]></description>
		<generator>JForum - http://www.jforum.net</generator>
			<item>
				<title>如何將Properties排序輸出?</title>
				<description><![CDATA[ 參考[url=http://forum.java.sun.com/thread.jspa?threadID=478160&amp;messageID=2222582]How to sort Properties ??[/url]這篇裡面最簡單的作法是: 
<br>
[code]public class SortedProperties extends Properties { 
<br>
 public synchronized Enumeration keys() { 
<br>
 Enumeration keysEnum = super.keys(); 
<br>
 Vector keyList = new Vector(); 
<br>
 while(keysEnum.hasMoreElements()){ 
<br>
 keyList.add(keysEnum.nextElement()); 
<br>
 } 
<br>
 Collections.sort(keyList); 
<br>
 return keyList.elements(); 
<br>
 } 
<br>
} 
<br>
[/code] 
<br>
使用方式就跟原本的Properties類別一樣: 
<br>
[code] 
<br>
 Properties p = new SortedProperties(); 
<br>
 p.putAll(globals.installation); 
<br>
 try { 
<br>
 FileOutputStream out = new FileOutputStream(globals.installationConfig); 
<br>
 p.store(out, "Installation specific configuration options"); 
<br>
 out.close(); 
<br>
 } 
<br>
 catch (IOException e) { 
<br>
 throw new ForumException(e); 
<br>
 } 
<br>
[/code]]]></description>
				<guid isPermaLink="true">https://forum.andowson.com/posts/preList/143/231.page</guid>
				<link>https://forum.andowson.com/posts/preList/143/231.page</link>
				<pubDate><![CDATA[Mon, 3 Sep 2007 00:08:29]]> GMT</pubDate>
				<author><![CDATA[ andowson]]></author>
			</item>
	</channel>
</rss>