Last active
August 6, 2019 08:32
-
-
Save malys/b4e2b866201b6d29bc1cc1170fccd5e6 to your computer and use it in GitHub Desktop.
[Properties] Compare #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
| Properties props = new Properties(); | |
| props.load(new FileInputStream("D:\\Developpement\\archi\\idm\\rh-sso-theme-lyra\\src\\main\\resources\\theme\\lyra\\login\\messages\\messages_en.properties")) | |
| // from now you have Properties object with your data. | |
| // since properties extends Hashtable the task is done. | |
| // if you still need keys in list, say | |
| List<Object> keys = new ArrayList<Object>(props.keySet()) | |
| keys=keys.toSorted() | |
| //println keys.join("\n") | |
| Properties props2 = new Properties(); | |
| props2.load(new FileInputStream("D:\\Developpement\\archi\\idm\\rh-sso-theme-lyra\\src\\main\\resources\\theme\\lyra\\login\\messages\\messages_fr.properties")) | |
| // from now you have Properties object with your data. | |
| // since properties extends Hashtable the task is done. | |
| // if you still need keys in list, say | |
| List<Object> keys2 = new ArrayList<Object>(props2.keySet()) | |
| keys2=keys2.toSorted() | |
| //println keys2.join("\n") | |
| //println keys.intersect( keys2 ).join("\n") | |
| def commons = keys.intersect(keys2) | |
| def difference = keys.plus(keys2) | |
| difference.removeAll(commons) | |
| Iterable<String> iter= difference | |
| for (String t : iter) { | |
| println "${t}=${props.get(t)==null?'':props.get(t)}" | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment