| Utility.java |
1 /*
2 * Copyright 2000-2001,2004 The Apache Software Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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 }
51 catch (Exception e) {
52
53 WSRPXHelper.throwX(ErrorCodes.PROPERTY_FILE_NOT_FOUND, e);
54
55 }
56
57 return null;
58
59 }
60
61 }