KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > javabb > infra > MaintainProperties


1 package org.javabb.infra;
2
3 import java.io.FileInputStream JavaDoc;
4 import java.util.Properties JavaDoc;
5
6 /**
7  * @author Dalton Camargo - <a HREF="mailto:dalton@ag2.com.br">dalton@ag2.com.br</a> <Br>
8  * AG2 - Agencia de Inteligencia Digital S.A.<Br>
9  * <a HREF="http://www.ag2.com.br">http://www.ag2.com.br</a><Br>
10  * Nosso <i>www</i> e mais <b>inteligente</b>!
11  */

12 public class MaintainProperties {
13     private FileInputStream JavaDoc localFile = null;
14     private Properties JavaDoc properties = null;
15     
16     
17     public MaintainProperties(FileInputStream JavaDoc file) throws Exception JavaDoc{
18         localFile = file;
19         loadProperties();
20     }
21     
22     private void loadProperties() throws Exception JavaDoc{
23         if(localFile == null){
24             throw new Exception JavaDoc("Property is null: FileInputStream !");
25         }
26         properties = new Properties JavaDoc();
27         properties.load(localFile);
28     }
29     
30     public String JavaDoc getProperty(String JavaDoc nmProperty) throws Exception JavaDoc{
31         if(properties == null){
32             throw new Exception JavaDoc("Property is null !");
33         }
34         if(nmProperty == null) {
35             return null;
36         }
37         return properties.getProperty(nmProperty);
38     }
39 }
40
Popular Tags