=========================== source code ================================================================================================================================================================================= =====================================================================================================================================================
Package SUNCERTIFY.UTILITY;
import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.util.Hashtable; import Java.util.ITerator; import java.util.properties; import java.util.set; import java.util.logging.logmanager;
Import SUNCERTIFY.CONSTRAINTS; Import SUNCERTIFY.DB.SYSTEMEXCEPTION;
public class ConfiguraionUtil {public static final Properties readProperties () throws SystemException {Properties properties = new Properties (); try {properties.load (new FileInputStream (new File (Constraints.FILE_PROPERTIES)));} catch (FileNotFoundException e) {throw new SystemException ("can not find the suceptify.properties);} catch (ioException e) {throw new systemException (" I / O Error Occurs When Reading THE ");} Return Properties
public static final void writeProperties (final Hashtable table) throws SystemException {Properties properties = new Properties (); FileOutputStream out = null; try {Set keys = table.keySet (); Iterator iter = keys.iterator (); String content = " "; While (ore) {string key = (String) iter.next (); Object value = table.get (key); content = key " = " value " / n ";} out = new FileOutputStream (new File (Constraints.FILE_PROPERTIES)); out.write (content.getBytes ()); properties.store (out, null);} catch (FileNotFoundException e) {throw new SystemException ( "Can not find the SUNCERTIFY.PROPERTIES FILE ");} catch (ioException e) {throw new systemException (" I / O Error Occurs When Reading THE ");} Finally {Try {Out.Close (); } Catch (ioexception e) {out = null;}}}}
REFERENCE:
http://www.dimi.uniud.it/labs/documentazione/java1.0-tutorial/java/cmdlineargs/properties.html
http://javaalmanac.com/egs/java.util/props.html