Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/359.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 使用ResourceBundle读取属性文件有什么好处?_Java_Selenium_Properties - Fatal编程技术网

Java 使用ResourceBundle读取属性文件有什么好处?

Java 使用ResourceBundle读取属性文件有什么好处?,java,selenium,properties,Java,Selenium,Properties,这里我使用了两种代码来读取属性文件,但我不确定我的selenium automation(selenium automation)中哪一种用于读取“特定于语言环境的对象”(来自javadoc)。如果您不想要区域设置敏感对象,例如美国英语和加拿大法语或其他语言之间存在差异的对象,请不要使用ResourceBundle。用于读取“特定于语言环境的对象”(来自javadoc)。如果您不想要区域设置敏感对象,例如美国英语和加拿大法语或其他语言之间存在差异的对象,请不要使用ResourceBundle。

这里我使用了两种代码来读取属性文件,但我不确定我的selenium automation(selenium automation)

中哪一种用于读取“特定于语言环境的对象”(来自javadoc)。如果您不想要区域设置敏感对象,例如美国英语和加拿大法语或其他语言之间存在差异的对象,请不要使用
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);
}