zoukankan      html  css  js  c++  java
  • 保存属性至xml并读取

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

    public class PropertiesDemo04 {
        public static void main(String[] args) {
            Properties pro = new Properties();
            pro.setProperty("BJ", "Beijing");
            pro.setProperty("DJ", "TOKYO");
            pro.setProperty("DB", "oSA");
            File file = new File("E:" + File.separator + "area.xml");
            try {
                pro.storeToXML(new FileOutputStream(file), "AREA INFO");
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }
            try {
                pro.loadFromXML(new FileInputStream(file));
            } catch (InvalidPropertiesFormatException e) {
                e.printStackTrace();
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }
            System.out.println("DJ:" + pro.getProperty("DJ"));
        }
    }

  • 相关阅读:
    TypeError: 'encoding' is an invalid keyword argument for this function 解决Python 2.7
    valid-palindrome leetcode C++
    valid-palindrome leetcode C++
    word-break-ii leetcode C++
    word-break-ii leetcode C++
    word-break leetcoder C++
    word-break leetcoder C++
    word-ladder leetcoder C++
    word-ladder leetcoder C++
    triangle leetcode C++
  • 原文地址:https://www.cnblogs.com/vonk/p/3961341.html
Copyright © 2011-2022 走看看