<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    posts - 33,  comments - 17,  trackbacks - 0
     1// 從資源文件里讀取值的類,文件后綴不一定要.Properties,只要里面內容如:url=www.cnsec.net 
     2可通過key(url)取得值-www.cnsec.net,簡單、強大 
     3import java.io.File;
     4import java.io.FileInputStream;
     5import java.io.FileNotFoundException;
     6import java.io.IOException;
     7import java.util.Properties;
     8/**
     9 * ReadProperties.java
    10 * Description: 讀取操作屬性配置文件
    11 * @author li.b
    12 * @version 2.0
    13 * Jun 26, 2008
    14 */

    15public class ReadProperties {
    16
    17    /**
    18     * Description: 獲取屬性配置文件
    19     * @param path 資源文件路徑
    20     * @return    Properties Object
    21     * @throws FileNotFoundException
    22     * @throws IOException
    23     */

    24    public static Properties getProperties(String path) throws FileNotFoundException, IOException{
    25        Properties props = null;
    26        File file = new File(path);
    27        if(file.exists() && file.isFile()){
    28            props = new Properties();
    29            props.load(new FileInputStream(file));
    30        }
    else{
    31            System.out.println(file.toString() + "不存在!");
    32        }

    33        return props;
    34    }

    35    
    36    /**
    37     * Description: 從屬性文件獲取值
    38     * @param props Properties Object
    39     * @param key
    40     * @return 通過key匹配到的value
    41     */

    42    public static String getValue(Properties props,String key,String encod){
    43        String result = "";
    44        String en = "";
    45        String localEN = System.getProperty("file.encoding");
    46        if(encod !=null && !encod.equals("") ){
    47            en = encod;
    48        }
    else{
    49            en = localEN;
    50        }

    51        try {
    52            key = new String(key.getBytes(en),"ISO-8859-1");
    53            result = props.getProperty(key);
    54            if(!result.equals("")){
    55                    result = new String(result.getBytes("ISO-8859-1"),en);                
    56            }

    57        }
     catch (Exception e) {
    58        }
    finally{
    59            if(result == null)result = "";
    60            return result;
    61        }

    62    }

    63    
    64    public static String getValue(Properties props,String key){
    65        return getValue(props, key, "");
    66    }

    67
    68}
    posted on 2008-07-23 17:43 scea2009 閱讀(413) 評論(0)  編輯  收藏

    只有注冊用戶登錄后才能發(fā)表評論。


    網站導航:
     

    <2008年7月>
    293012345
    6789101112
    13141516171819
    20212223242526
    272829303112
    3456789

    常用鏈接

    留言簿(1)

    隨筆分類

    隨筆檔案

    PL/SQL存儲過程與函數

    搜索

    •  

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 免费看国产曰批40分钟| 中文字幕天天躁日日躁狠狠躁免费| 中文字幕乱码免费视频| 久久亚洲日韩看片无码| 无码精品国产一区二区三区免费 | 在线视频免费观看www动漫| 美女视频黄频a免费大全视频| 成年人免费网站在线观看| 中文字幕亚洲综合久久综合 | 精品国产日韩久久亚洲| 女人张开腿等男人桶免费视频 | 国产免费久久精品99久久| 免费看黄视频网站| 国产成人精品亚洲日本在线 | 99久久免费国产精精品| 亚洲AV日韩AV永久无码绿巨人| 久久久久成人片免费观看蜜芽| 亚洲男女性高爱潮网站| 成人毛片免费观看视频大全| 日韩色日韩视频亚洲网站| 亚洲日本在线观看视频| 无码国产精品一区二区免费vr| 亚洲国产美女精品久久久久| 黄a大片av永久免费| 国产成人精品免费视频大全| 亚洲国产综合91精品麻豆| 毛片免费观看网址| 九九久久精品国产免费看小说| 亚洲AV日韩AV永久无码下载| 岛国片在线免费观看| 国产高清视频免费在线观看| 亚洲色欲www综合网| 尤物永久免费AV无码网站| 嫩草成人永久免费观看| 国产亚洲sss在线播放| 精品国产人成亚洲区| 国产福利视精品永久免费| 日韩精品无码永久免费网站| 久久久久亚洲AV无码网站| 国产女高清在线看免费观看| 久久免费视频网站|