posts - 97,  comments - 93,  trackbacks - 0

          In a project, we can write a class to read the properties.As following,

          import java.io.InputStream;
          import java.io.IOException;
          import java.util.Properties;

          public class PropertyReader{
             private static Properties property = null;
            
             static{
                InputSteam stream = null;
                try{
                  stream=PropertyReader.class.getResourceAsStream("/resource/properties.properties");
                  property = new Properties();
                  property.load(stream);
                }catch(IOException e){
                    e.printStackTrace();
                }finally{
                    if(stream != null){
                       try{
                          stream.close();
                       }catch(IOException e){
                          e.printStackTrace();
                       }           
                    }
                }
             }
             public static String getResource(String key){
               if(property == null){
                 return null;// init error;
               }
               
               return property.getProperty(key);
             }
          }

          posted on 2007-04-05 08:13 wqwqwqwqwq 閱讀(486) 評論(0)  編輯  收藏 所屬分類: Simple Java
          <2007年4月>
          25262728293031
          1234567
          891011121314
          15161718192021
          22232425262728
          293012345




          常用鏈接

          留言簿(10)

          隨筆分類(95)

          隨筆檔案(97)

          文章檔案(10)

          相冊

          J2ME技術網站

          java技術相關

          mess

          搜索

          •  

          最新評論

          閱讀排行榜

          校園夢網網絡電話,中國最優秀的網絡電話
          主站蜘蛛池模板: 丹凤县| 永嘉县| 米脂县| 定襄县| 芮城县| 通城县| 涞水县| 界首市| 安乡县| 黑水县| 大兴区| 中阳县| 榆林市| 轮台县| 秀山| 和硕县| 平利县| 攀枝花市| 元氏县| 天峻县| 县级市| 长宁县| 商水县| 安吉县| 疏勒县| 丽江市| 潢川县| 射阳县| 乌鲁木齐县| 太谷县| 屯昌县| 土默特右旗| 平罗县| 泉州市| 巴中市| 沧源| 寿阳县| 赣州市| 广宁县| 贞丰县| 聂拉木县|