package read_dir;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
public class ReadDirector {
private static String dir_name="D:\xunlei";
public static void main(String[] args) {
ReadDirector rd=new ReadDirector();
List filenames=rd.getFiles(dir_name);
for(int i =0;i
System.out.println("The file name of "+(i+1)+" is: "+str);
}
}
public List getFiles (String dirname){
File dir=new File(dirname);
File []files=dir.listFiles();
List file_names=new ArrayList();
for(int i=0;i
file_names.add(files[i].getName()+"=>It is a folder");
}
if(files[i].isHidden()){//Determine whether it is a hidden file
file_names.add(files[i].getName()+"=>It is a hidden text");
}
if (files[i].isFile()&&(!files[i].isHidden())){//Determine whether it is a file and it cannot be a hidden file
file_names.add(files[i].getName());
}
}
return file_names;
}
}