ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、视频、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
## 方法 * 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); } ~~~