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 閱讀(485) 評論(0)  編輯  收藏 所屬分類: Simple Java
          <2007年4月>
          25262728293031
          1234567
          891011121314
          15161718192021
          22232425262728
          293012345




          常用鏈接

          留言簿(10)

          隨筆分類(95)

          隨筆檔案(97)

          文章檔案(10)

          相冊

          J2ME技術網站

          java技術相關

          mess

          搜索

          •  

          最新評論

          閱讀排行榜

          校園夢網網絡電話,中國最優秀的網絡電話
          主站蜘蛛池模板: 邓州市| 汝南县| 黑龙江省| 鄢陵县| 刚察县| 宜君县| 龙川县| 清河县| 延边| 万载县| 新兴县| 商洛市| 新化县| 凌云县| 兴和县| 永州市| 炉霍县| 九江县| 凤台县| 黄石市| 连云港市| 新巴尔虎右旗| 巴东县| 临朐县| 恩施市| 邵武市| 烟台市| 云霄县| 准格尔旗| 定边县| 日照市| 静安区| 西乌珠穆沁旗| 乳源| 长岛县| 中江县| 改则县| 高邑县| 衡东县| 内江市| 梁平县|