home *** CD-ROM | disk | FTP | other *** search
Java Source | 2003-12-19 | 1.1 KB | 35 lines |
- package it.favaroni.wrapper;
-
- public class PropertiesFileHandler {
- private String propertiesFile = null;
- private static PropertiesFileHandler propertiesfilehandler = null;
- private java.util.Properties applicationProps = null;
- private java.io.FileInputStream in = null;
- /**
- * PropertiesFileHandler constructor comment.
- */
- private PropertiesFileHandler(String url) {
- super();
- propertiesFile = url;
- System.out.println("load " + propertiesFile + " in memory.....");
- try {
- //read properties file
- applicationProps = new java.util.Properties();
- in = new java.io.FileInputStream(propertiesFile);
- applicationProps.load(in);
- in.close();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- public static PropertiesFileHandler getInstance(String url) {
- if (propertiesfilehandler == null) {
- propertiesfilehandler = new PropertiesFileHandler(url);
- }
- return propertiesfilehandler;
- }
- public String readProperty(String key) {
- return applicationProps.getProperty(key);
- }
- }
-