58,452
社区成员
发帖
与我相关
我的任务
分享
public class Student {
private String name;
private int ID;
private int age;
public Student(String name, int iD, int age) {
super();
this.name = name;
ID = iD;
this.age = age;
}
private ArrayList<Student> I=new ArrayList<Student>();
private String savePath="save/";
public void cun(){
Getlist A=new Getlist();
File a=new File(savePath+"/");
if(!a.exists()){
a.mkdirs();
}
for(int i=0;i<I.size();i++){
File f=new File(savePath+"/students"+i+"_Imfor.txt");
if(!f.exists()){
try{f.createNewFile();}
catch (IOException e) {
e.printStackTrace();
}
}
try {
FileWriter fw=new FileWriter(f,false);
fw.write(I.get(i).getName());
fw.flush();
fw.write(I.get(i).getId());
fw.flush();
fw.write(I.get(i).getAge());
fw.flush();
fw.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}