home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 77 / IOPROG_77.ISO / tips / Java / ConnectionPool / src / it / favaroni / wrapper / PropertiesFileHandler.java
Encoding:
Java Source  |  2003-12-19  |  1.1 KB  |  35 lines

  1. package it.favaroni.wrapper;
  2.  
  3. public class PropertiesFileHandler {
  4.     private String propertiesFile = null;
  5.     private static PropertiesFileHandler propertiesfilehandler = null;
  6.     private java.util.Properties applicationProps = null;
  7.     private java.io.FileInputStream in = null;
  8. /**
  9.  * PropertiesFileHandler constructor comment.
  10.  */
  11. private PropertiesFileHandler(String url) {
  12.     super();
  13.     propertiesFile = url;
  14.     System.out.println("load " + propertiesFile + " in memory.....");
  15.     try {
  16.         //read properties file
  17.         applicationProps = new java.util.Properties();
  18.         in = new java.io.FileInputStream(propertiesFile);
  19.         applicationProps.load(in);
  20.         in.close();
  21.     } catch (Exception e) {
  22.         e.printStackTrace();
  23.     }
  24. }
  25. public static PropertiesFileHandler getInstance(String url) {
  26.     if (propertiesfilehandler == null) {
  27.         propertiesfilehandler = new PropertiesFileHandler(url);
  28.     }
  29.     return propertiesfilehandler;
  30. }
  31. public String readProperty(String key) {
  32.     return applicationProps.getProperty(key);
  33. }
  34. }
  35.