public static List<String> readfile1(String filepath) throws FileNotFoundException, IOException {
List<String> list = new ArrayList<>();
try {
File file = new File(filepath);
if (file.isDirectory()) {
// System.out.println("文件夹");
String[] filelist = file.list();
for (int i = 0; i < filelist.length; i++) {
File readfile = new File(filepath + "\\" + filelist[i]);
if (readfile.isDirectory()) {
readfile(filepath + "\\" + filelist[i]);
System.out.println("path=" + filepath + "\\" + filelist[i]);
File f = new File(filepath + "\\" + filelist[i]);
Calendar cal = Calendar.getInstance();
long time = f.lastModified();
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
cal.setTimeInMillis(time);
System.out.println("修改时间 " + formatter.format(cal.getTime()));
}
}
}
// System.out.println(list.size());
return list;
} catch (FileNotFoundException e) {
System.out.println("readfile() Exception:" + e.getMessage());
}
System.out.println("ok");
return list;
}
最后输出的是文件夹列表信息和文件夹的修改时间!!!