/*************************************************************************** * Property * Property file is very useful to store and get the program parameters. **************************************************************************/ /** * Get the property from the file name. * @param filename the file name for property file * @return */ public static java.util.Properties propertiesGet(String filename) { return Ts.propertiesGet(new java.io.File(filename)); } /** * Get the property from the File object. * @param file the File object that is a property file * @return */ public static java.util.Properties propertiesGet(java.io.File file) { java.util.Properties props = new java.util.Properties(); java.io.FileInputStream in = null; try { in = new java.io.FileInputStream(file); } catch (java.io.FileNotFoundException ex) { Ts.printErr(ex); } try { props.load(in); in.close(); } catch (java.io.IOException ex) { Ts.printErr(ex); } return props; } /** * Print every rows of the property file. * @param props the Property object */ public static void propertiesPrint(java.util.Properties props) { java.util.Set keys = props.keySet(); String key = null; String val = null; int i = 0; for (Object key_o : keys) { key = (String) key_o; val = props.getProperty(key.toString()); System.out.println("" + i + " :: " + key + " :: " + val); } } public static void printErr(java.lang.Exception ex) { printErr(ex.getMessage()); }