package zuoye;

public class person {
private String name;
private int age;

public person( int age,String name) {
this.name = name;
this.age = age;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
}

package zuoye;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;

public class zuoye1 {
public static void main (String[] args){
try {
fu();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static void fu() throws IOException{
ArrayList<person> a=new ArrayList<person>();
a.add(new person(1,"aaa"));
a.add(new person(2,"bbb"));
a.add(new person(3,"ddd"));
File d=new File("D://aaa1");
boolean d1 = d.mkdirs();
System.out.println(d1);
Iterator<person> b = a.iterator();
for(person i:a){
String c = i.getName();
File a1=new File("D:\\aaa1\\",c+".tet");
boolean c1 = a1.createNewFile();
System.out.println(c1);
}
File[] c2=d.listFiles();
for(File i:c2){
System.out.println(i);
}
}
}

posted on 2019-03-24 18:15  ~王~  阅读(253)  评论(0编辑  收藏  举报