用Java自帶的Properties類訪問配置文件
Properties?props?
=
?
new
?Properties();
InputStream?in? = ?Main. class .getResourceAsStream( " p.properties " );?? // p.properties文件與當前類同包
props.load(in);?? // 將配置文件內容加載到Properties對象中
BufferedReader?input? = ? new ?BufferedReader( new ?InputStreamReader(System.in));?? // 從屏幕接收用戶輸入
String?key? = ?input.readLine();
System.out.println(props.get(key);
InputStream?in? = ?Main. class .getResourceAsStream( " p.properties " );?? // p.properties文件與當前類同包
props.load(in);?? // 將配置文件內容加載到Properties對象中
BufferedReader?input? = ? new ?BufferedReader( new ?InputStreamReader(System.in));?? // 從屏幕接收用戶輸入
String?key? = ?input.readLine();
System.out.println(props.get(key);
posted on 2009-10-21 10:54 Rick Qin 閱讀(252) 評論(0) 編輯 收藏 所屬分類: Java