View Javadoc
1 /*** 2 * DiskPropertiesReader.java 3 * 4 * Project: Dependency Tool 5 * 6 * WHEN WHO WHAT 7 * 06.06.2003 pko initial public release 8 * 20.02.2003 pko creation 9 * 10 * Copyright 2003 ELCA Informatique SA 11 * Av. de la Harpe 22-24, 1000 Lausanne 13, Switzerland 12 * www.elca.ch 13 * 14 * This library is free software; you can redistribute it and/or 15 * modify it under the terms of the GNU Lesser General Public License 16 * as published by the Free Software Foundation; either version 2.1 of 17 * the License, or (at your option) any later version. 18 * 19 * This library is distributed in the hope that it will be useful, but 20 * WITHOUT ANY WARRANTY; without even the implied warranty of 21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 * Lesser General Public License for more details. 23 * 24 * You should have received a copy of the GNU Lesser General Public 25 * License along with this library; if not, write to the Free Software 26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 27 * USA 28 */ 29 30 package ch.elca.dependency.util; 31 32 import java.io.FileInputStream; 33 import java.io.InputStream; 34 import java.util.Properties; 35 36 /*** 37 * The class <code>DiskFileReader</code> used to read user properties 38 * stored in plain Files. Usually such properties may and have to be 39 * set by users. 40 * 41 * @author Pawel Kowalski 42 * @version 1.0-beta 43 */ 44 public class DiskFileReader implements PropertiesReader { 45 46 //****************************************************************************************/ 47 // singleton part 48 //****************************************************************************************/ 49 50 /*** 51 * The only instance of the DiskFileReader. 52 */ 53 private static DiskFileReader m_instance = null; 54 55 /*** 56 * Get the one and only instance of this class. 57 * 58 * @return a <code>DiskFileReader</code> value 59 */ 60 public static synchronized DiskFileReader singleton() { 61 if (m_instance == null) { 62 m_instance = new DiskFileReader(); 63 } 64 return m_instance; 65 } 66 67 //****************************************************************************************/ 68 // public methods 69 //****************************************************************************************/ 70 71 /*** 72 * Get the named properties as a Stream. 73 * 74 * @param propertiesName a <code>String</code> value 75 * @return an <code>InputStream</code> value 76 */ 77 public InputStream getPropertiesAsStream(String propertiesName) { 78 try { 79 return new FileInputStream(propertiesName); 80 } catch (Exception e) { 81 return null; 82 } 83 } 84 85 /*** 86 * Get the named Properties. 87 * 88 * @param propertiesName a <code>String</code> value 89 * @return a <code>Properties</code> value 90 */ 91 public Properties getProperties(String propertiesName) { 92 Properties properties = new Properties(); 93 InputStream propertiesStream = getPropertiesAsStream(propertiesName); 94 if (propertiesStream != null) { 95 try { 96 properties.load(getPropertiesAsStream(propertiesName)); 97 } catch (Exception e){ 98 ; 99 } 100 } 101 return properties; 102 } 103 }

This page was automatically generated by Maven