import java.io.*;
public class List {
public static void main(String[] args) throws IOException {
File file=new File("D:\\f");
//showDir(file);
//FileReader br=new FileReader("D:\\f");
//FileWriter fw=new FileWriter("D:\\f1");
File f1=new File("D:\\r");
Boolean b=f1.mkdir();
copy(file);
System.out.println(b+" jfdjsjfsjfksjfdjf");
}
public static void showDir(File dir){
System.out.println(dir);
File[] files=dir.listFiles();
for(int i=0;i<files.length;i++){
if(files[i].isDirectory()){
showDir(files[i]);
}
else
System.out.println(files[i]);
}
}
public static void copy(File fi) throws IOException{
File[] ff=fi.listFiles();
for(int j=0;j<ff.length;j++){
if(ff[j].isDirectory()){
String k=ff[j].getName();
ff[j].mkdir();
copy(ff[j]);
}
else{
FileReader fr=new FileReader(ff[j]);
char[] ch=new char[1024];
int num=0;
if((num=fr.read(ch))!=-1)
System.out.println(new String(ch,0,num));
fr.close();
}
}
}
}
|
|