1 package booking.model.util;
2
3 import java.io.File;
4 import java.io.FileInputStream;
5 import java.io.InputStream;
6 import java.util.Properties;
7
8 import org.apache.log4j.Logger;
9
10 public class LoadPropertiesUtil {
11
12
13 private static Logger log = Logger.getLogger(LoadPropertiesUtil.class);
14
15 public static Properties loadProperties(String filePath) {
16
17 Properties properties = new Properties();
18 try {
19
20 if (log.isDebugEnabled()) {
21 log.debug("loadProperties() - Inicio");
22 }
23
24
25 properties.load(new FileInputStream(filePath));
26
27 } catch (Exception e) {
28
29 ClassLoader cl = LoadPropertiesUtil.class.
30 getClassLoader();
31 InputStream inputFile = cl.getResourceAsStream(filePath);
32 properties.load(inputFile);
33
34 } finally {
35
36 if (properties.isEmpty()) {
37 log.error("Error cargando properties: "
38 + new File(filePath).getAbsolutePath());
39 }
40
41 if (log.isDebugEnabled()) {
42 log.debug("loadProperties() - Fin");
43 }
44 return properties;
45 }
46
47 }
48 }