Created
October 23, 2012 08:18
-
-
Save kjunine/3937602 to your computer and use it in GitHub Desktop.
sorted properties
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.Collections; | |
| import java.util.Enumeration; | |
| import java.util.Properties; | |
| import java.util.Vector; | |
| @SuppressWarnings("serial") | |
| public class SortedProperties extends Properties { | |
| @SuppressWarnings({ "rawtypes", "unchecked" }) | |
| public synchronized Enumeration keys() { | |
| Enumeration keys = super.keys(); | |
| Vector sorted = new Vector(); | |
| while (keys.hasMoreElements()) { | |
| sorted.add(keys.nextElement()); | |
| } | |
| Collections.sort(sorted); | |
| return sorted.elements(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment