将lisi写入文件
自动换行:setProperty可以连续set会
public class InputArrayObject {
public static void main(String[] args) throws IOException {
ArrayList<Student> list = new ArrayList<>();
list.add(new Student("张三",18));
list.add(new Student("李四",19));
list.add(new Student("王五",20));
list.add(new Student("赵六",21));
Properties properties = new Properties();
PrintWriter printWriter = new PrintWriter("project/Test/student.properties");
for (Student student : list) {
properties.setProperty(student.getName(),String.valueOf(student.getAge()));
}
properties.list(printWriter);
printWriter.close();
}
}