proerties操作

来源:互联网 发布:nginx url 转发 编辑:程序博客网 时间:2024/06/10 05:06

application.properties

关于properties的路径问题,参看java其他里面的一篇日志

里面内容:

qemu.url=qemu:///system
#qemu.url=qemu+ssh:///root@192.168.43.239/system
domain.name=ubuntu8

#xuhong
domain.cpu=1
domain.memory=524288
domain.diskpath=/var/lib/libvirt/images/ubuntu8.img
# action 1action 1 启动 2 停机 3 重启 4挂起 5复原 6创建 7修改 8 删除
domain.action=1



操作办法:

    private static String getProperties(){
        Properties pro =  new Properties();
        try {
            InputStream is = TestClientAPI.class.getClassLoader().getResourceAsStream("/application.properties");
            pro.load(is);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        String domainName = pro.getProperty("domain.name");
        return domainName;
    }