Java 使用ResourceBundle读取属性文件有什么好处?
这里我使用了两种代码来读取属性文件,但我不确定我的selenium automation(selenium automation)中哪一种用于读取“特定于语言环境的对象”(来自javadoc)。如果您不想要区域设置敏感对象,例如美国英语和加拿大法语或其他语言之间存在差异的对象,请不要使用Java 使用ResourceBundle读取属性文件有什么好处?,java,selenium,properties,Java,Selenium,Properties,这里我使用了两种代码来读取属性文件,但我不确定我的selenium automation(selenium automation)中哪一种用于读取“特定于语言环境的对象”(来自javadoc)。如果您不想要区域设置敏感对象,例如美国英语和加拿大法语或其他语言之间存在差异的对象,请不要使用ResourceBundle。用于读取“特定于语言环境的对象”(来自javadoc)。如果您不想要区域设置敏感对象,例如美国英语和加拿大法语或其他语言之间存在差异的对象,请不要使用ResourceBundle。
ResourceBundle
。用于读取“特定于语言环境的对象”(来自javadoc)。如果您不想要区域设置敏感对象,例如美国英语和加拿大法语或其他语言之间存在差异的对象,请不要使用ResourceBundle
。
public class Query {
private final String BUNDLE_NAME="Query";
private final ResourceBundle RB=ResourceBundle.getBundle(BUNDLE_NAME);
public Query(){
}
public String getValue(String key) throws FileNotFoundException{
return RB.getString(key);
}
}
public class Query_properties {
public static Properties pos=new Properties();
public static String sqlData(String q) throws IOException {
try{
FileInputStream fis=new FileInputStream(System.getProperty("user.dir")+"/Query.properties");
pos.load(fis);
pos.getProperty(q);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
return pos.getProperty(q);
}