zoukankan      html  css  js  c++  java
  • java properties

    java properties

    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.FileNotFoundException;
    import java.util.Properties;

    public class PropertiesTest {
        public static void main(String[] args) throws Exception {
            // from file "myProperties.txt"
            Properties p = new Properties();
            try{
                FileInputStream propFile = new FileInputStream("myProperties.txt");
                p.load(propFile);
                p.list(System.out);
            } catch (FileNotFoundException e)  {
            }
           
            // Write properties file.
            try {
                p.setProperty("lastdir", "c:\\tmp");
                p.store(new FileOutputStream("myProperties.txt"), null);
            } catch (IOException e) {
            }
        }
    }


    String propFile = this.getServletContext().getRealPath("/") + "/WEB-INF/classes/security.properties";
    Properties prop = new Properties();
    try{ prop.load(new FileInputStream(propFile)); }
    catch(IOException ioe){ throw (new SecurityException(("Failed to initialize properties with default properties file " + propFile))); }
    SecureStream ss = new SecureStream (in, out, prop);
  • 相关阅读:
    ATOM编辑器插件
    说说关于IE浏览器兼容性
    git命令
    Vue js 的生命周期详解
    Flexbox 布局教程
    到底vuex是什么?
    CSS3 动画 animation和@keyframes
    zabbix添加触发器Triggers
    zabbix邮件报警
    修改zabbix监控项刷新时间
  • 原文地址:https://www.cnblogs.com/kentyshang/p/807394.html
Copyright © 2011-2022 走看看