KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > sample > google > common > util > PropertyLoader


1 package sample.google.common.util;
2
3 import java.io.IOException JavaDoc;
4 import java.io.InputStream JavaDoc;
5 import java.util.Properties JavaDoc;
6
7 /*
8  * Copyright 2004,2005 The Apache Software Foundation.
9  *
10  * Licensed under the Apache License, Version 2.0 (the "License");
11  * you may not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  *
22  *
23  */

24 public class PropertyLoader {
25
26     private static String JavaDoc googleKey;
27     private static String JavaDoc googleEndpointURL;
28     private static String JavaDoc googleEndpointServiceName;
29
30     static{
31         try {
32             Properties JavaDoc prop = new Properties JavaDoc();
33             Class JavaDoc clazz = new Object JavaDoc().getClass();
34             InputStream JavaDoc stream = clazz.getResourceAsStream("/sample/google/common/conf/key.properties");
35             prop.load(stream);
36
37             googleKey = prop.getProperty("google.key");
38             googleEndpointURL = prop.getProperty("google.url");
39             googleEndpointServiceName = prop.getProperty("google.name");
40
41         } catch (IOException JavaDoc e) {
42             System.exit(0);
43         }
44
45     }
46     public static String JavaDoc getGoogleKey() {
47         return googleKey;
48     }
49
50     public static String JavaDoc getGoogleEndpointURL() {
51         return googleEndpointURL;
52     }
53
54     public static String JavaDoc getGoogleEndpointServiceName() {
55         return googleEndpointServiceName;
56     }
57
58     public static void setGoogleKey(String JavaDoc googleKey) {
59         PropertyLoader.googleKey = googleKey;
60     }
61
62 }
63
Popular Tags