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);
  • 相关阅读:
    [Codeforces 933A]A Twisty Movement
    [Codeforces 100633J]Ceizenpok’s formula
    [HAOI 2011]向量
    [JSOI 2008]最大数
    [Codeforces 750E]New Year and Old Subsequence
    [BZOJ 3439]Kpm的MC密码
    [TJOI 2013]单词
    [SCOI 2011]糖果
    [BZOJ 2160]拉拉队排练
    [AtCoder arc090F]Number of Digits
  • 原文地址:https://www.cnblogs.com/kentyshang/p/807394.html
Copyright © 2011-2022 走看看