1 import java.io.File;
2 import java.io.FileInputStream;
3 import java.io.IOException;
4 import java.io.InputStream;
5 import java.util.Properties;
6
7 public class PropertiesUtil {
8
9 private Properties appProperties = new Properties();
10
11 /**
12 * 加载文件路径
13 */
14 public void getAppProperties(String path) throws IOException {
15 InputStream in = new FileInputStream( new File(path));
16 appProperties.load(in);
17 in.close();
18 }
19
20 /**
21 * 获取属性
22 * @param strFieldName - the field name
23 * @return strPro the field content
24 */
25 public String getSpecialProperty(String strFieldName) throws IOException {
26 String strProperty = strFieldName;
27 String strPro = appProperties.getProperty(strProperty);
28 return strPro != null ? strPro.trim() : strPro;
29 }
30
31 }