KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > icesoft > jsfmeta > util > ConfigStorage


1
2 /*
3  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4  *
5  * "The contents of this file are subject to the Mozilla Public License
6  * Version 1.1 (the "License"); you may not use this file except in
7  * compliance with the License. You may obtain a copy of the License at
8  * http://www.mozilla.org/MPL/
9  *
10  * Software distributed under the License is distributed on an "AS IS"
11  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
12  * License for the specific language governing rights and limitations under
13  * the License.
14  *
15  * The Original Code is ICEfaces 1.5 open source software code, released
16  * November 5, 2006. The Initial Developer of the Original Code is ICEsoft
17  * Technologies Canada, Corp. Portions created by ICEsoft are Copyright (C)
18  * 2004-2006 ICEsoft Technologies Canada, Corp. All Rights Reserved.
19  *
20  * Contributor(s): _____________________.
21  *
22  * Alternatively, the contents of this file may be used under the terms of
23  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"
24  * License), in which case the provisions of the LGPL License are
25  * applicable instead of those above. If you wish to allow use of your
26  * version of this file only under the terms of the LGPL License and not to
27  * allow others to use your version of this file under the MPL, indicate
28  * your decision by deleting the provisions above and replace them with
29  * the notice and other provisions required by the LGPL License. If you do
30  * not delete the provisions above, a recipient may use your version of
31  * this file under either the MPL or the LGPL License."
32  *
33  */

34
35 package com.icesoft.jsfmeta.util;
36
37 import java.io.BufferedInputStream JavaDoc;
38 import java.io.File JavaDoc;
39 import java.io.FileInputStream JavaDoc;
40 import java.io.FileNotFoundException JavaDoc;
41 import java.io.IOException JavaDoc;
42 import java.util.Properties JavaDoc;
43
44 /**
45  *
46  * ConfigStorage pick up properties file
47  */

48 public class ConfigStorage {
49     
50     private String JavaDoc fileName;
51     
52     private ConfigStorage(String JavaDoc fileName) {
53         this.fileName = fileName;
54     }
55  
56     public static ConfigStorage getInstance(String JavaDoc fileName){
57         
58         return new ConfigStorage(fileName);
59     }
60     
61     public Properties JavaDoc loadProperties(){
62         
63         Properties JavaDoc properties = new Properties JavaDoc();
64         try {
65             properties.load(new BufferedInputStream JavaDoc(new FileInputStream JavaDoc(new File JavaDoc(fileName))));
66         } catch (FileNotFoundException JavaDoc e){
67             e.printStackTrace();
68             System.exit(1);
69         } catch (IOException JavaDoc e){
70             e.printStackTrace();
71             System.exit(1);
72         }
73         
74         return properties;
75     }
76     
77     
78     
79 }
80
Popular Tags