01: /*
02: * Copyright 2000-2001,2004 The Apache Software Foundation.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: /*
18:
19: */
20:
21: package org.apache.wsrp4j.util;
22:
23: import java.io.InputStream;
24: import java.util.Properties;
25:
26: import org.apache.wsrp4j.exception.ErrorCodes;
27: import org.apache.wsrp4j.exception.WSRPException;
28: import org.apache.wsrp4j.exception.WSRPXHelper;
29:
30: public class Utility {
31:
32: /**
33: * Loads a property file with the given name using the class loader.
34: *
35: * @return A <code>Properties</code> object containig the properties in the file
36: * @throws WSRPException if any error occured
37: **/
38: public static Properties loadPropertiesFromFile(String fileName)
39: throws WSRPException {
40:
41: try {
42: // read in .properties-file
43: InputStream in = Utility.class.getClassLoader()
44: .getResourceAsStream(fileName);
45: Properties properties = new Properties();
46: properties.load(in);
47:
48: return properties;
49:
50: } catch (Exception e) {
51:
52: WSRPXHelper.throwX(ErrorCodes.PROPERTY_FILE_NOT_FOUND, e);
53:
54: }
55:
56: return null;
57:
58: }
59:
60: }
|