Here you can find the source of readAllKeys(String propertyFileName, String xmlFileName)
Parameter | Description |
---|---|
propertyFileName | a parameter |
xmlFileName | a parameter |
Parameter | Description |
---|---|
IOException | an exception |
private static void readAllKeys(String propertyFileName, String xmlFileName) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.FileInputStream; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.util.Properties; import java.util.Set; public class Main { /**//from ww w. jav a 2 s.c o m * read all the keys from the given property files * @param propertyFileName * @param xmlFileName * @throws IOException */ private static void readAllKeys(String propertyFileName, String xmlFileName) throws IOException { System.out.println("Start of readAllKeys"); Properties prop = new Properties(); FileReader reader = new FileReader(propertyFileName); prop.load(reader); Set<Object> keys = prop.keySet(); for (Object obj : keys) { System.out.println( propertyFileName + ":: Key=" + obj.toString() + "::value=" + prop.getProperty(obj.toString())); } //loading xml file now, first clear existing properties prop.clear(); InputStream is = new FileInputStream(xmlFileName); prop.loadFromXML(is); keys = prop.keySet(); for (Object obj : keys) { System.out.println( xmlFileName + ":: Key=" + obj.toString() + "::value=" + prop.getProperty(obj.toString())); } //Now free all the resources is.close(); reader.close(); System.out.println("End of readAllKeys"); } }