🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
## 方法 * store():保存数据到文件. * load():从文件中加载数据. ## 实例 ~~~ public static void main(String[] args) throws IOException { // write(); read(); } //持久化数据到文件中 public static void write() throws IOException { //定义properties Properties ps = new Properties(); ps.setProperty("张三", "18"); ps.setProperty("李四", "20"); ps.setProperty("王五", "16"); //把ps的数据持久化到文件中 ps.store(new FileWriter("info.properties"), "comment"); //comment是描述 } public static void read() throws IOException { Properties ps = new Properties(); //从文件中读取数据 ps.load(new FileReader("info.properties")); System.out.println(ps); } ~~~