1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package net.fckeditor.handlers;
22
23 import java.io.BufferedInputStream;
24 import java.io.InputStream;
25 import java.util.Properties;
26
27 import org.slf4j.Logger;
28 import org.slf4j.LoggerFactory;
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47 public class PropertiesLoader {
48 private static final Logger logger = LoggerFactory.getLogger(PropertiesLoader.class);
49 private static Properties properties = new Properties();
50
51 static {
52
53
54 InputStream in = PropertiesLoader.class
55 .getResourceAsStream("default.properties");
56
57 if (in == null) {
58 logger.error("default.properties not found");
59 throw new RuntimeException("default.properties not found");
60 } else {
61 if (!(in instanceof BufferedInputStream))
62 in = new BufferedInputStream(in);
63
64 try {
65 properties.load(in);
66 in.close();
67 logger.debug("default.properties loaded");
68 } catch (Exception e) {
69 logger.error("Error while processing default.properties");
70 throw new RuntimeException(
71 "Error while processing default.properties", e);
72 }
73 }
74
75
76 InputStream in2 = PropertiesLoader.class
77 .getResourceAsStream("/fckeditor.properties");
78
79 if (in2 == null) {
80 logger.info("fckeditor.properties not found");
81 } else {
82
83 if (!(in2 instanceof BufferedInputStream))
84 in2 = new BufferedInputStream(in2);
85
86 try {
87 properties.load(in2);
88 in2.close();
89 logger.debug("fckeditor.properties loaded");
90 } catch (Exception e) {
91 logger.error("Error while processing fckeditor.properties");
92 throw new RuntimeException(
93 "Error while processing fckeditor.properties", e);
94 }
95
96 }
97 }
98
99
100
101
102
103
104
105
106
107 public static String getProperty(final String key) {
108 return properties.getProperty(key);
109 }
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125 public static void setProperty(final String key, final String value) {
126 properties.setProperty(key, value);
127 }
128 }