Properties获取属性

 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 }
posted @ 2012-10-20 20:19  将来的老大爷  阅读(296)  评论(0编辑  收藏  举报

如果本页面列出的内容侵犯了您的权益,请告知。
知识共享许可协议
996.icu