[英]How to read properties file in java
我想寫一個Java程序
問題:
我有屬性文件,在屬性文件中包含
range="1,5,35-50,100"
我應該從命令提示符或JSP獲取輸入作為范圍,並打印出消息,例如this is a range
或者this is not a range
讓我們考慮以下I / O應該看起來像
Input:1
Output:this is a range
Input:2
Output:this is not a range
Input:37
Output:this is a range
Input:60
Output:this is not a range
Input:100
Output:this is a range
有人可以幫我嗎,謝謝
您可以讀取屬性文件值,將它們存儲在DataStructure中,讓它說Array,並使用contains
方法檢查從命令行讀取的值是否包含在數組中。 如果您在編寫代碼方面需要任何幫助,或者遇到任何困難,請告訴我。
String bundle = "your properties file name without .properties";
ResourceBundle rb = ResourceBundle.getBundle(bundle);
String range = rb.getString("range");
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.